Sha256: 850f97e4f67921a6c5460c041bb6fbaa276ce4d3ed8c8723cda8e98a726b01f6
Contents?: true
Size: 1.24 KB
Versions: 10
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module Overcommit::HookContext # Contains helpers related to contextual information used by commit-msg hooks. class CommitMsg < Base def empty_message? commit_message.strip.empty? end # User commit message stripped of comments and diff (from verbose output). def commit_message commit_message_lines.join end # Updates the commit message to the specified text. def update_commit_message(message) ::File.open(commit_message_file, 'w') do |file| file.write(message) end end def commit_message_lines raw_commit_message_lines. take_while { |line| !line.start_with?('diff --git') }. reject { |line| line.start_with?(comment_character) } end def comment_character @comment_character ||= Overcommit::GitConfig.comment_character end def commit_message_file @args[0] end 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 private def raw_commit_message_lines ::IO.readlines(commit_message_file) end end end
Version data entries
10 entries across 10 versions & 2 rubygems