Class: Overcommit::HookContext::PrepareCommitMsg

Inherits:
Base
  • Object
show all
Defined in:
lib/overcommit/hook_context/prepare_commit_msg.rb

Overview

Contains helpers related to contextual information used by prepare-commit-msg hooks.

Instance Method Summary collapse

Methods inherited from Base

#all_files, #cleanup_environment, #execute_hook, #hook_class_name, #hook_script_name, #hook_type_name, #initialize, #input_lines, #input_string, #modified_files, #post_fail_message, #setup_environment

Constructor Details

This class inherits a constructor from Overcommit::HookContext::Base

Instance Method Details

#commit_message_filenameObject

Returns the name of the file that contains the commit log message


8
9
10
# File 'lib/overcommit/hook_context/prepare_commit_msg.rb', line 8

def commit_message_filename
  @args[0]
end

#commit_message_sourceObject

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)


18
19
20
# File 'lib/overcommit/hook_context/prepare_commit_msg.rb', line 18

def commit_message_source
  @args[1]&.to_sym
end

#commit_message_source_refObject

Returns the commit's SHA-1. If commit_message_source is :commit, it's passed through the command-line.


24
25
26
# File 'lib/overcommit/hook_context/prepare_commit_msg.rb', line 24

def commit_message_source_ref
  @args[2] || `git rev-parse HEAD`
end

#lockObject

Lock for the pre_commit_message file. Should be shared by all prepare-commit-message hooks


30
31
32
# File 'lib/overcommit/hook_context/prepare_commit_msg.rb', line 30

def lock
  @lock ||= Monitor.new
end