Class: Overcommit::HookContext::RunAll
- Defined in:
- lib/overcommit/hook_context/run_all.rb
Overview
Simulates a pre-commit context pretending that all files have been changed.
This results in pre-commit hooks running against the entire repository, which is useful for automated CI scripts.
Instance Method Summary collapse
- #hook_class_name ⇒ Object
- #hook_script_name ⇒ Object
- #hook_type_name ⇒ Object
- #initial_commit? ⇒ Boolean
- #modified_files ⇒ Object
-
#modified_lines_in_file(file) ⇒ Set
Returns all lines in the file since in this context the entire repo is being scrutinized.
Methods inherited from Base
#all_files, #cleanup_environment, #execute_hook, #initialize, #input_lines, #input_string, #post_fail_message, #setup_environment
Constructor Details
This class inherits a constructor from Overcommit::HookContext::Base
Instance Method Details
#hook_class_name ⇒ Object
25 26 27 |
# File 'lib/overcommit/hook_context/run_all.rb', line 25 def hook_class_name 'PreCommit' end |
#hook_script_name ⇒ Object
33 34 35 |
# File 'lib/overcommit/hook_context/run_all.rb', line 33 def hook_script_name 'pre-commit' end |
#hook_type_name ⇒ Object
29 30 31 |
# File 'lib/overcommit/hook_context/run_all.rb', line 29 def hook_type_name 'pre_commit' end |
#initial_commit? ⇒ Boolean
37 38 39 40 41 |
# File 'lib/overcommit/hook_context/run_all.rb', line 37 def initial_commit? return @initial_commit unless @initial_commit.nil? @initial_commit = Overcommit::GitRepo.initial_commit? end |
#modified_files ⇒ Object
11 12 13 |
# File 'lib/overcommit/hook_context/run_all.rb', line 11 def modified_files @modified_files ||= all_files end |
#modified_lines_in_file(file) ⇒ Set
Returns all lines in the file since in this context the entire repo is being scrutinized.
20 21 22 23 |
# File 'lib/overcommit/hook_context/run_all.rb', line 20 def modified_lines_in_file(file) @modified_lines_in_file ||= {} @modified_lines_in_file[file] ||= Set.new(1..count_lines(file)) end |