Class: GitProc::AbstractMergeErrorBuilder
- Inherits:
-
Object
- Object
- GitProc::AbstractMergeErrorBuilder
show all
- Includes:
- AbstractErrorBuilder
- Defined in:
- lib/git-process/git_abstract_merge_error_builder.rb
Overview
noinspection RubyTooManyInstanceVariablesInspection
Instance Attribute Summary collapse
Instance Method Summary
collapse
#append_commands, #build_message, #commands, #shell_escaped_files
Constructor Details
#initialize(gitlib, error_message, continue_command) ⇒ AbstractMergeErrorBuilder
Returns a new instance of AbstractMergeErrorBuilder.
25
26
27
28
29
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 25
def initialize(gitlib, error_message, continue_command)
@gitlib = gitlib
@error_message = error_message
@continue_command = continue_command
end
|
Instance Attribute Details
#added ⇒ Object
101
102
103
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 101
def added
@added ||= status.added
end
|
#continue_command ⇒ Object
Returns the value of attribute continue_command.
22
23
24
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 22
def continue_command
@continue_command
end
|
#deleted ⇒ Object
106
107
108
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 106
def deleted
@deleted ||= status.deleted
end
|
#error_message ⇒ Object
Returns the value of attribute error_message.
22
23
24
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 22
def error_message
@error_message
end
|
#gitlib ⇒ Object
Returns the value of attribute gitlib.
22
23
24
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 22
def gitlib
@gitlib
end
|
#modified ⇒ Object
111
112
113
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 111
def modified
@modified ||= status.modified
end
|
#unmerged ⇒ Object
96
97
98
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 96
def unmerged
@unmerged ||= status.unmerged
end
|
Instance Method Details
#build_commands ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 67
def build_commands
commands = []
unless resolved_files.empty?
escaped_files = shell_escaped_files(resolved_files)
commands << "git add #{escaped_files}"
end
unless unresolved_files.empty?
mergeable = unresolved_files & modified
commands << "git mergetool #{shell_escaped_files(mergeable)}" unless mergeable.empty?
mergeable.each do |f|
commands << "# Verify '#{f}' merged correctly."
end
(unresolved_files & added).each do |f|
commands << "# '#{f}' was added in both branches; Fix the conflict."
end
commands << "git add #{shell_escaped_files(unresolved_files)}"
end
commands << continue_command if continue_command
commands
end
|
#find_resolved_files ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 42
def find_resolved_files
resolved_files = []
unmerged.each do |file|
resolved_file = (/Resolved '#{file}' using previous resolution./m =~ error_message)
resolved_files << file if resolved_file
end
resolved_files.sort
end
|
#human_message ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 54
def human_message
msg = 'There was a problem merging.'
unresolved_files.each do |file|
if modified.include? file
msg << "\n'#{file}' was modified in both branches."
end
end
msg
end
|
#resolved_files ⇒ Object
32
33
34
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 32
def resolved_files
@resolved_files ||= find_resolved_files
end
|
#unresolved_files ⇒ Object
37
38
39
|
# File 'lib/git-process/git_abstract_merge_error_builder.rb', line 37
def unresolved_files
@unresolved_files ||= (unmerged - resolved_files)
end
|