lib/middleman-deploy/strategies/git/base.rb in middleman-deploy-0.3.0 vs lib/middleman-deploy/strategies/git/base.rb in middleman-deploy-1.0.0
- old
+ new
@@ -1,17 +1,19 @@
module Middleman
module Deploy
module Strategies
module Git
class Base
- attr_accessor :branch, :build_dir, :remote, :commit_message
+ attr_accessor :branch, :build_dir, :remote, :commit_message, :user_name, :user_email
def initialize(build_dir, remote, branch, commit_message)
self.branch = branch
self.build_dir = build_dir
self.remote = remote
self.commit_message = commit_message
+ self.user_name = `git config --get user.name`
+ self.user_email = `git config --get user.email`
end
def process
raise NotImplementedError
end
@@ -35,12 +37,17 @@
end
def commit_branch(options = '')
message = self.commit_message ? self.commit_message : add_signature_to_commit_message('Automated commit')
- `git add -A`
- `git commit --allow-empty -am "#{message}"`
- `git push #{options} origin #{self.branch}`
+ run_or_fail("git add -A")
+ run_or_fail("git commit --allow-empty -am \"#{message}\"")
+ run_or_fail("git push #{options} origin #{self.branch}")
+ end
+
+ private
+ def run_or_fail(command)
+ system(command) || raise("ERROR running: #{command}")
end
end
end
end
end