class MGit::FFMergeCommand
Public Instance Methods
arity()
click to toggle source
# File lib/mgit/commands/ffmerge.rb, line 17 def arity [nil, 0] end
description()
click to toggle source
# File lib/mgit/commands/ffmerge.rb, line 25 def description 'merge all upstream tracking branches that can be fast-forwarded' end
execute(_)
click to toggle source
# File lib/mgit/commands/ffmerge.rb, line 3 def execute(_) Registry.chdir_each do |repo| branches = mergable_branches(repo) next if branches.empty? if repo.dirty? pwarn "Skipping repository #{repo.name} since it's dirty." next end merge_branches(repo, branches) end end
usage()
click to toggle source
# File lib/mgit/commands/ffmerge.rb, line 21 def usage 'ffmerge' end
Private Instance Methods
mergable_branches(repo)
click to toggle source
# File lib/mgit/commands/ffmerge.rb, line 33 def mergable_branches(repo) repo.remote_tracking_branches.select do |branch, upstream| !repo.unmerged_commits(branch, upstream).empty? end.keys end
merge_branch(branch)
click to toggle source
# File lib/mgit/commands/ffmerge.rb, line 54 def merge_branch(branch) System.git("checkout -q #{branch}", raise: true, print_stderr: true) System.git('merge --ff-only @{u}', raise: true, print_stderr: true) end
merge_branches(repo, branches)
click to toggle source
# File lib/mgit/commands/ffmerge.rb, line 39 def merge_branches(repo, branches) pinfo "Fast-forward merging branches in repository #{repo.name}..." cb = repo.current_branch begin branches.each { |b| merge_branch(b) } rescue GitError perror "Failed to merge a branch in repository #{repo.name}." pwarn 'Please visit this repository and check that everything\'s alright. Trying to set back to original working branch.' ensure System.git("checkout -q #{cb}", print_stderr: true) end end