Method: Overcommit::Hook::PrepareCommitMsg::Base#modify_commit_message

Defined in:
lib/overcommit/hook/prepare_commit_msg/base.rb

#modify_commit_messageObject



13
14
15
16
17
18
19
20
21
22
23
# 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