add ability to set custom commit message for git deploys

issue #64
This commit is contained in:
Nihad Abbasov 2014-05-24 23:35:14 +05:00
parent 08e392fc6b
commit efd66e7fca
4 changed files with 11 additions and 8 deletions

View file

@ -66,6 +66,7 @@ activate :deploy do |deploy|
# deploy.remote = "custom-remote" # remote name or git url, default: origin
# deploy.branch = "custom-branch" # default: gh-pages
# deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push
# deploy.commit_message = "custom-message" # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version`
end
```

View file

@ -5,7 +5,7 @@ require "middleman-core"
module Middleman
module Deploy
class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :password, :path, :clean, :remote, :branch, :strategy, :build_before, :flags); end
class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :password, :path, :clean, :remote, :branch, :strategy, :build_before, :flags, :commit_message); end
class << self
@ -25,6 +25,7 @@ module Middleman
options.remote ||= "origin"
options.branch ||= "gh-pages"
options.strategy ||= :force_push
options.commit_message ||= nil
options.build_before ||= false

View file

@ -8,7 +8,7 @@ module Middleman
camelized_strategy = self.options.strategy.to_s.split('_').map { |word| word.capitalize}.join
strategy_class_name = "Middleman::Deploy::Strategies::Git::#{camelized_strategy}"
strategy_instance = strategy_class_name.constantize.new(self.server_instance.build_dir, self.options.remote, self.options.branch)
strategy_instance = strategy_class_name.constantize.new(self.server_instance.build_dir, self.options.remote, self.options.branch, self.options.commit_message)
strategy_instance.process
end

View file

@ -3,12 +3,13 @@ module Middleman
module Strategies
module Git
class Base
attr_accessor :branch, :build_dir, :remote
attr_accessor :branch, :build_dir, :remote, :commit_message
def initialize(build_dir, remote, branch)
self.branch = branch
self.build_dir = build_dir
self.remote = remote
def initialize(build_dir, remote, branch, commit_message)
self.branch = branch
self.build_dir = build_dir
self.remote = remote
self.commit_message = commit_message
end
def process
@ -34,7 +35,7 @@ module Middleman
end
def commit_branch(options='')
message = add_signature_to_commit_message('Automated commit')
message = self.commit_message ? self.commit_message : add_signature_to_commit_message('Automated commit')
`git add -A`
`git commit --allow-empty -am "#{message}"`