class Overcommit::Hook::PrepareCommitMsg::Base

Functionality common to all prepare-commit-msg hooks.

Public Instance Methods

modify_commit_message() { |contents)| ... } click to toggle source
# File lib/overcommit/hook/prepare_commit_msg/base.rb, line 13
def modify_commit_message
  raise 'This expects a block!' unless block_given?

  # NOTE: this assumes all the hooks of the same type share the context's
  # memory. If that's not the case, this won't work.
  lock.synchronize do
    contents = File.read(commit_message_filename)
    File.open(commit_message_filename, 'w') do |f|
      f << (yield contents)
    end
  end
end