Class: Overcommit::HookContext::Diff
- Inherits:
-
Base
- Object
- Base
- Overcommit::HookContext::Diff
show all
- Defined in:
- lib/overcommit/hook_context/diff.rb
Overview
Simulates a pre-commit context based on the diff with another git ref.
This results in pre-commit hooks running against the changes between the current and another ref, which is useful for automated CI scripts.
Instance Method Summary
collapse
Methods inherited from Base
#all_files, #cleanup_environment, #execute_hook, #initialize, #input_lines, #input_string, #post_fail_message, #setup_environment
Instance Method Details
#hook_class_name ⇒ Object
21
22
23
|
# File 'lib/overcommit/hook_context/diff.rb', line 21
def hook_class_name
'PreCommit'
end
|
#hook_script_name ⇒ Object
29
30
31
|
# File 'lib/overcommit/hook_context/diff.rb', line 29
def hook_script_name
'pre-commit'
end
|
#hook_type_name ⇒ Object
25
26
27
|
# File 'lib/overcommit/hook_context/diff.rb', line 25
def hook_type_name
'pre_commit'
end
|
#initial_commit? ⇒ Boolean
33
34
35
|
# File 'lib/overcommit/hook_context/diff.rb', line 33
def initial_commit?
@initial_commit ||= Overcommit::GitRepo.initial_commit?
end
|
#modified_files ⇒ Object
11
12
13
|
# File 'lib/overcommit/hook_context/diff.rb', line 11
def modified_files
@modified_files ||= Overcommit::GitRepo.modified_files(refs: @options[:diff])
end
|
#modified_lines_in_file(file) ⇒ Object
15
16
17
18
19
|
# File 'lib/overcommit/hook_context/diff.rb', line 15
def modified_lines_in_file(file)
@modified_lines ||= {}
@modified_lines[file] ||= Overcommit::GitRepo.(file,
refs: @options[:diff])
end
|