class Overcommit::HookContext::RunAll
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.
Public Instance Methods
Source
# File lib/overcommit/hook_context/run_all.rb, line 25 def hook_class_name 'PreCommit' end
Source
# File lib/overcommit/hook_context/run_all.rb, line 33 def hook_script_name 'pre-commit' end
Source
# File lib/overcommit/hook_context/run_all.rb, line 29 def hook_type_name 'pre_commit' end
Source
# 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
Source
# File lib/overcommit/hook_context/run_all.rb, line 11 def modified_files @modified_files ||= all_files end
Source
# 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
Returns all lines in the file since in this context the entire repo is being scrutinized.
@param file [String] @return [Set]
Private Instance Methods
Source
# File lib/overcommit/hook_context/run_all.rb, line 45 def count_lines(file) File.foreach(file).count end