Class: MGit::LogCommand

Inherits:
Command show all
Defined in:
lib/mgit/commands/log.rb

Instance Method Summary collapse

Methods inherited from Command

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

Instance Method Details

#descriptionObject



22
23
24
# File 'lib/mgit/commands/log.rb', line 22

def description
  'show unmerged commits for all remote-tracking branches'
end

#execute(args) ⇒ Object



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

def execute(args)
  Registry.chdir_each do |repo|
    repo.remote_tracking_branches.each do |branch, upstream|
      uc = unmerged_commits(branch, upstream)
      next if uc.empty?

      puts "In repository #{repo.name}, branch #{upstream} the following commits were made:".yellow
      longest_name = uc.map { |c| c[:author].size }.max
      uc.each do |c|
        puts "#{c[:commit]}  #{c[:author].ljust(longest_name, ' ')}  #{c[:subject]}"
      end
    end
  end
end

#usageObject



18
19
20
# File 'lib/mgit/commands/log.rb', line 18

def usage
  'log'
end