Merge pull request #65 from NARKOZ/custom-commit-message
add ability to set custom commit message for git deploys
This commit is contained in:
commit
84e86e2530
4 changed files with 11 additions and 8 deletions
|
@ -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
|
||||
```
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
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}"`
|
||||
|
|
Loading…
Reference in a new issue