Class: MGit::FFMergeCommand

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

Instance Method Summary collapse

Methods inherited from Command

create, #help, instance_each, list, register_alias, register_command

Instance Method Details

#descriptionObject



27
28
29
# File 'lib/mgit/commands/ffmerge.rb', line 27

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
20
21
# File 'lib/mgit/commands/ffmerge.rb', line 3

def execute(args)
  raise TooManyArgumentsError.new(self) if args.size != 0

  Registry.chdir_each do |repo|
    if repo.dirty?
      puts "Skipping repository #{repo.name} since it's dirty.".red
      next
    end 

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

    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



23
24
25
# File 'lib/mgit/commands/ffmerge.rb', line 23

def usage
  'ffmerge'
end