30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/routes/git_update.rb', line 30
def update_branch_single
@git.check_for_uncommitted_files(true)
@git.repo_loop.each do |repo_dir|
current_branch = @git.current_branch_for_repo(repo_dir)
commands = Array.new
if current_branch != Brightpearl::Git::MASTER
commands << 'git checkout master'
end
commands << 'git pull'
if current_branch != Brightpearl::Git::MASTER
commands << "git checkout #{current_branch}"
commands << 'git pull'
commands << 'git merge master'
end
results = Brightpearl::Terminal::command(commands, repo_dir)
if current_branch != Brightpearl::Git::MASTER
if results[3] == false
@git.ask_to_setup_remote_tracking(current_branch, repo_dir)
end
if results[4] == false
Brightpearl::Terminal::error('Merge conflict occurred', ["Unable to successfully merge #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} into #{Brightpearl::Terminal::format_branch(current_branch)} on #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))}", "Please #{Brightpearl::Terminal::format_action('open an IDE')}\x1B[38;5;240m and resolve your conflicts as soon as this script has finished executing."])
end
end
if @opts[:push] && current_branch != Brightpearl::Git::MASTER
Brightpearl::Terminal::command("git push origin #{current_branch}", repo_dir)
elsif @opts[:push] && current_branch == Brightpearl::Git::MASTER
Brightpearl::Terminal::warning("#{Brightpearl::Terminal::format_action('push')} to #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)} not allowed!", ["Your #{Brightpearl::Terminal::format_directory(@git.get_repo_shorthand(repo_dir))} repo is currently on #{Brightpearl::Terminal::format_branch(Brightpearl::Git::MASTER)}","The script will not perform a #{Brightpearl::Terminal::format_action('push')} as requested for safety reasons."])
end
end
@git.check_for_stash(true)
end
|