Class: Overcommit::HookContext::PrePush

Inherits:
Base
  • Object
show all
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

Instance Method Summary collapse

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

#argsObject

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_filesObject



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_refsObject



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_nameObject



8
9
10
# File 'lib/overcommit/hook_context/pre_push.rb', line 8

def remote_name
  @args[0]
end

#remote_urlObject



12
13
14
# File 'lib/overcommit/hook_context/pre_push.rb', line 12

def remote_url
  @args[1]
end