Class: Overcommit::HookContext::PrePush
- Inherits:
-
Base
- Object
- Base
- Overcommit::HookContext::PrePush
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
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
31
32
33
|
# File 'lib/overcommit/hook_context/pre_push.rb', line 31
def modified_files
@modified_files ||= pushed_refs.map(&:modified_files).flatten.uniq
end
|
#modified_lines_in_file(file) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/overcommit/hook_context/pre_push.rb', line 35
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
25
26
27
28
29
|
# File 'lib/overcommit/hook_context/pre_push.rb', line 25
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_ref_deletion? ⇒ Boolean
16
17
18
19
20
21
22
23
|
# File 'lib/overcommit/hook_context/pre_push.rb', line 16
def remote_ref_deletion?
return @remote_ref_deletion if defined?(@remote_ref_deletion)
@remote_ref_deletion ||= input_lines.
first&.
split(' ')&.
first == '(deleted)'
end
|
#remote_url ⇒ Object
12
13
14
|
# File 'lib/overcommit/hook_context/pre_push.rb', line 12
def remote_url
@args[1]
end
|