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.
6 7 8 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 6 def args @args end |
Instance Method Details
#modified_files ⇒ Object
22 23 24 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 22 def modified_files @modified_files ||= pushed_refs.map(&:modified_files).flatten.uniq end |
#modified_lines_in_file(file) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 26 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
16 17 18 19 20 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 16 def pushed_refs input_lines.map do |line| PushedRef.new(*line.split(' ')) end end |
#remote_name ⇒ Object
8 9 10 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 8 def remote_name @args[0] end |
#remote_url ⇒ Object
12 13 14 |
# File 'lib/overcommit/hook_context/pre_push.rb', line 12 def remote_url @args[1] end |