Class: FlashFlow::Resolve
- Inherits:
-
Object
- Object
- FlashFlow::Resolve
show all
- Defined in:
- lib/flash_flow/resolve.rb
Defined Under Namespace
Classes: NothingToResolve
Instance Method Summary
collapse
Constructor Details
#initialize(git_config, branch_info_file, opts = {}) ⇒ Resolve
Returns a new instance of Resolve.
11
12
13
14
15
16
|
# File 'lib/flash_flow/resolve.rb', line 11
def initialize(git_config, branch_info_file, opts={})
@logger = opts[:logger]
@branch_info_file = branch_info_file
@cmd_runner = CmdRunner.new(logger: @logger)
@git = Git.new(git_config, @logger)
end
|
Instance Method Details
#bash_message ⇒ Object
64
65
66
|
# File 'lib/flash_flow/resolve.rb', line 64
def bash_message
puts "\nPlease fix the following conflicts and then 'exit':\n#{unresolved_conflicts.join("\n")}\n\n"
end
|
#git_reset ⇒ Object
56
57
58
|
# File 'lib/flash_flow/resolve.rb', line 56
def git_reset
@git.run("reset --hard HEAD")
end
|
#launch_bash ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/flash_flow/resolve.rb', line 68
def launch_bash
bash_message
with_init_file do |file|
system("bash --init-file #{file} -i")
end
end
|
#manual_instructions ⇒ Object
18
19
20
21
|
# File 'lib/flash_flow/resolve.rb', line 18
def manual_instructions
branch = check_for_conflict
puts manual_not_merged_instructions(branch)
end
|
#manual_not_merged_instructions(branch) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/flash_flow/resolve.rb', line 87
def manual_not_merged_instructions(branch)
"\nRun the following commands to fix the merge conflict and then re-run flash_flow:\n pushd \#{flash_flow_directory}\n git checkout \#{branch.conflict_sha}\n git merge \#{working_branch}\n # Resolve the conflicts\n git add <conflicted files>\n git commit --no-edit\n popd\n\n EOS\nend\n"
|
#merge_conflicted ⇒ Object
51
52
53
54
|
# File 'lib/flash_flow/resolve.rb', line 51
def merge_conflicted
@git.run("checkout #{branch.conflict_sha}")
@git.run("merge origin/#{working_branch}")
end
|
#rerere ⇒ Object
60
61
62
|
# File 'lib/flash_flow/resolve.rb', line 60
def rerere
@git.run("rerere")
end
|
#start ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/flash_flow/resolve.rb', line 23
def start
check_for_conflict
in_shadow_repo do
in_working_branch do
merge_conflicted
if unresolved_conflicts.empty?
puts "You have already resolved all conflicts."
else
launch_bash
rerere
unless unresolved_conflicts.empty?
puts "There are still unresolved conflicts in these files:\n#{unresolved_conflicts.join("\n")}\n\n"
end
end
git_reset
end
end
end
|
#unresolved_conflicts ⇒ Object
47
48
49
|
# File 'lib/flash_flow/resolve.rb', line 47
def unresolved_conflicts
@git.unresolved_conflicts
end
|
#with_init_file {|filename| ... } ⇒ Object
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/flash_flow/resolve.rb', line 76
def with_init_file
filename = '.flash_flow_init'
File.open(filename, 'w') do |f|
f.puts(init_file_contents)
end
yield filename
File.delete(filename)
end
|