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
23
24
25
|
# File 'lib/overcommit/hook_context/diff.rb', line 23
def hook_class_name
'PreCommit'
end
|
#hook_script_name ⇒ Object
31
32
33
|
# File 'lib/overcommit/hook_context/diff.rb', line 31
def hook_script_name
'pre-commit'
end
|
#hook_type_name ⇒ Object
27
28
29
|
# File 'lib/overcommit/hook_context/diff.rb', line 27
def hook_type_name
'pre_commit'
end
|
#initial_commit? ⇒ Boolean
#modified_files ⇒ Object
13
14
15
|
# File 'lib/overcommit/hook_context/diff.rb', line 13
def modified_files
@modified_files ||= Overcommit::GitRepo.modified_files(refs: @options[:diff])
end
|
#modified_lines_in_file(file) ⇒ Object
17
18
19
20
21
|
# File 'lib/overcommit/hook_context/diff.rb', line 17
def modified_lines_in_file(file)
@modified_lines ||= {}
@modified_lines[file] ||= Overcommit::GitRepo.(file,
refs: @options[:diff])
end
|