class Overcommit::HookContext::PrepareCommitMsg
Contains helpers related to contextual information used by prepare-commit-msg hooks.
Public Instance Methods
commit_message_filename()
click to toggle source
Returns the name of the file that contains the commit log message
# File lib/overcommit/hook_context/prepare_commit_msg.rb, line 8 def commit_message_filename @args[0] end
commit_message_source()
click to toggle source
Returns the source of the commit message, and can be: message (if a -m or -F option was given); template (if a -t option was given or the configuration option commit.template is set); merge (if the commit is a merge or a .git/MERGE_MSG file exists); squash (if a .git/SQUASH_MSG file exists); or commit, followed by a commit SHA-1 (if a -c, -C or –amend option was given)
# File lib/overcommit/hook_context/prepare_commit_msg.rb, line 18 def commit_message_source @args[1]&.to_sym end
commit_message_source_ref()
click to toggle source
Returns the commit's SHA-1. If commit_message_source
is :commit, it's passed through the command-line.
# File lib/overcommit/hook_context/prepare_commit_msg.rb, line 24 def commit_message_source_ref @args[2] || `git rev-parse HEAD` end
lock()
click to toggle source
Lock for the pre_commit_message file. Should be shared by all prepare-commit-message hooks
# File lib/overcommit/hook_context/prepare_commit_msg.rb, line 30 def lock @lock ||= Monitor.new end