class FlashFlow::Resolve
Public Class Methods
new(git_config, branch_info_file, opts={})
click to toggle source
# 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 = ShadowGit.new(git_config, @logger) end
Public Instance Methods
bash_message()
click to toggle source
# File lib/flash_flow/resolve.rb, line 62 def bash_message puts "\nNote: You are in a special flash_flow directory (#{Dir.pwd}). The files still open in your editor will not reflect the merge conflicts, open them from this shell to get the conflicted versions.\n\nPlease fix the following conflicts and then 'exit':\n#{unresolved_conflicts.join("\n")}\n\n" end
git_reset()
click to toggle source
# File lib/flash_flow/resolve.rb, line 54 def git_reset @git.run("reset --hard HEAD") end
launch_bash()
click to toggle source
# File lib/flash_flow/resolve.rb, line 66 def launch_bash bash_message with_init_file do |file| system("bash --init-file #{file} -i") end end
manual_instructions()
click to toggle source
# File lib/flash_flow/resolve.rb, line 18 def manual_instructions check_for_conflict puts manual_not_merged_instructions end
manual_not_merged_instructions()
click to toggle source
# File lib/flash_flow/resolve.rb, line 85 def manual_not_merged_instructions <<-EOS Run the following commands to fix the merge conflict and then re-run flash_flow: pushd #{flash_flow_directory} git checkout #{branch.conflict_sha} git merge #{working_branch} # Resolve the conflicts git add <conflicted files> git commit --no-edit popd EOS end
merge_conflicted()
click to toggle source
# File lib/flash_flow/resolve.rb, line 49 def merge_conflicted @git.run("checkout #{branch.conflict_sha}") @git.run("merge #{@git.remote}/#{working_branch}") end
rerere()
click to toggle source
# File lib/flash_flow/resolve.rb, line 58 def rerere @git.run("rerere") end
start()
click to toggle source
# File lib/flash_flow/resolve.rb, line 23 def start check_for_conflict 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
unresolved_conflicts()
click to toggle source
# File lib/flash_flow/resolve.rb, line 45 def unresolved_conflicts @git.unresolved_conflicts end
with_init_file() { |filename| ... }
click to toggle source
# File lib/flash_flow/resolve.rb, line 74 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
Private Instance Methods
branch()
click to toggle source
# File lib/flash_flow/resolve.rb, line 106 def branch @branch ||= data.saved_branches.detect { |branch| branch.ref == working_branch } end
check_for_conflict()
click to toggle source
# File lib/flash_flow/resolve.rb, line 139 def check_for_conflict raise NothingToResolve.new("The current branch (#{working_branch}) does not appear to be in conflict.") unless branch.conflict_sha end
data()
click to toggle source
# File lib/flash_flow/resolve.rb, line 102 def data @data ||= Data::Base.new({}, @branch_info_file, @git, logger: @logger) end
flash_flow_directory()
click to toggle source
# File lib/flash_flow/resolve.rb, line 122 def flash_flow_directory @git.flash_flow_dir end
in_working_branch() { || ... }
click to toggle source
# File lib/flash_flow/resolve.rb, line 114 def in_working_branch @git.in_dir do @git.in_branch(working_branch) do yield end end end
init_file_contents()
click to toggle source
# File lib/flash_flow/resolve.rb, line 126 def init_file_contents <<-EOS # Commented this one out because it was causing lots of spurious "saving session..." type messages # [[ -s /etc/profile ]] && source /etc/profile [[ -s ~/.bash_profile ]] && source ~/.bash_profile [[ -s ~/.bash_login ]] && source ~/.bash_login [[ -s ~/.profile ]] && source ~/.profile [[ -s ~/.bashrc ]] && source ~/.bashrc PS1='flash_flow resolve: (type "exit" after your conflicts are resolved)$ ' EOS end
working_branch()
click to toggle source
# File lib/flash_flow/resolve.rb, line 110 def working_branch @git.working_branch end