class Overcommit::HookContext::CommitMsg
Contains helpers related to contextual information used by commit-msg hooks.
Public Instance Methods
Source
# File lib/overcommit/hook_context/commit_msg.rb, line 35 def comment_character @comment_character ||= Overcommit::GitConfig.comment_character end
Source
# File lib/overcommit/hook_context/commit_msg.rb, line 18 def commit_message commit_message_lines.join end
User commit message stripped of comments and diff (from verbose output).
Source
# File lib/overcommit/hook_context/commit_msg.rb, line 39 def commit_message_file @args[0] end
Source
# File lib/overcommit/hook_context/commit_msg.rb, line 29 def commit_message_lines raw_commit_message_lines. take_while { |line| !line.start_with?('diff --git') }. reject { |line| line.start_with?(comment_character) } end
Source
# File lib/overcommit/hook_context/commit_msg.rb, line 13 def empty_message? commit_message.strip.empty? end
Source
# File lib/overcommit/hook_context/commit_msg.rb, line 43 def post_fail_message "Failed commit message:\n#{commit_message_lines.join.chomp}\n\n" \ "Try again with your existing commit message by running:\n" \ "git commit --edit --file=#{commit_message_file}" end
Source
# File lib/overcommit/hook_context/commit_msg.rb, line 23 def update_commit_message(message) ::File.open(commit_message_file, 'w') do |file| file.write(message) end end
Updates the commit message to the specified text.
Private Instance Methods
Source
# File lib/overcommit/hook_context/commit_msg.rb, line 51 def raw_commit_message_lines ::IO.readlines(commit_message_file) end