Class: Overcommit::HookContext::PrePush
- Defined in:
- lib/overcommit/hook_context/pre_push.rb
Overview
Contains helpers related to contextual information used by pre-push hooks.
Defined Under Namespace
Classes: PushedRef
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
Instance Method Summary collapse
- #modified_files ⇒ Object
- #modified_lines_in_file(file) ⇒ Object
- #pushed_refs ⇒ Object
- #remote_name ⇒ Object
- #remote_url ⇒ Object
Methods inherited from Base
#all_files, #cleanup_environment, #execute_hook, #hook_class_name, #hook_script_name, #hook_type_name, #initialize, #input_lines, #input_string, #post_fail_message, #setup_environment
Constructor Details
This class inherits a constructor from Overcommit::HookContext::Base
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
4 5 6 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 4 def args @args end |
Instance Method Details
#modified_files ⇒ Object
20 21 22 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 20 def modified_files @modified_files ||= pushed_refs.map(&:modified_files).flatten.uniq end |
#modified_lines_in_file(file) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 24 def modified_lines_in_file(file) @modified_lines ||= {} @modified_lines[file] = pushed_refs.each_with_object(Set.new) do |pushed_ref, set| set.merge(pushed_ref.modified_lines_in_file(file)) end end |
#pushed_refs ⇒ Object
14 15 16 17 18 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 14 def pushed_refs input_lines.map do |line| PushedRef.new(*line.split(' ')) end end |
#remote_name ⇒ Object
6 7 8 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 6 def remote_name @args[0] end |
#remote_url ⇒ Object
10 11 12 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 10 def remote_url @args[1] end |