diff --git a/README.md b/README.md index 042691c..319b486 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/lib/middleman-deploy/extension.rb b/lib/middleman-deploy/extension.rb index 9882b06..58eaf3b 100644 --- a/lib/middleman-deploy/extension.rb +++ b/lib/middleman-deploy/extension.rb @@ -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 diff --git a/lib/middleman-deploy/methods/git.rb b/lib/middleman-deploy/methods/git.rb index b23627f..d772013 100644 --- a/lib/middleman-deploy/methods/git.rb +++ b/lib/middleman-deploy/methods/git.rb @@ -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 diff --git a/lib/middleman-deploy/strategies/git/base.rb b/lib/middleman-deploy/strategies/git/base.rb index 5304a92..cafce65 100644 --- a/lib/middleman-deploy/strategies/git/base.rb +++ b/lib/middleman-deploy/strategies/git/base.rb @@ -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}"`