Merge pull request #65 from NARKOZ/custom-commit-message

add ability to set custom commit message for git deploys
This commit is contained in:
Tom Vaughan 2014-05-24 14:55:38 -04:00
commit 84e86e2530
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.remote = "custom-remote" # remote name or git url, default: origin
# deploy.branch = "custom-branch" # default: gh-pages # deploy.branch = "custom-branch" # default: gh-pages
# deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push # 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 end
``` ```

View file

@ -5,7 +5,7 @@ require "middleman-core"
module Middleman module Middleman
module Deploy 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 class << self
@ -25,6 +25,7 @@ module Middleman
options.remote ||= "origin" options.remote ||= "origin"
options.branch ||= "gh-pages" options.branch ||= "gh-pages"
options.strategy ||= :force_push options.strategy ||= :force_push
options.commit_message ||= nil
options.build_before ||= false 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 camelized_strategy = self.options.strategy.to_s.split('_').map { |word| word.capitalize}.join
strategy_class_name = "Middleman::Deploy::Strategies::Git::#{camelized_strategy}" 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 strategy_instance.process
end end

View file

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