Class: MGit::FFMergeCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/mgit/commands/ffmerge.rb

Instance Method Summary collapse

Methods inherited from Command

execute, instance_each, list, register_alias, register_command

Methods included from Output

#perror, #pinfo, #ptable, #pwarn

Instance Method Details

#arityObject



21
22
23
# File 'lib/mgit/commands/ffmerge.rb', line 21

def arity
  [nil, 0]
end

#descriptionObject



29
30
31
# File 'lib/mgit/commands/ffmerge.rb', line 29

def description
  'merge all upstream tracking branches that can be fast-forwardeded'
end

#execute(args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mgit/commands/ffmerge.rb', line 3

def execute(args)
  Registry.chdir_each do |repo|
    if repo.dirty?
      pwarn "Skipping repository #{repo.name} since it's dirty."
      next
    end 

    pinfo "Fast-forward merging branches in repository #{repo.name}..."

    cb = repo.current_branch
    repo.remote_tracking_branches.each do |b, u|
      `git checkout -q #{b}`
      `git merge --ff-only @{u}`
    end
    `git checkout -q #{cb}`
  end
end

#usageObject



25
26
27
# File 'lib/mgit/commands/ffmerge.rb', line 25

def usage
  'ffmerge'
end