Class: MGit::LogCommand

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

Instance Method Summary collapse

Methods inherited from Command

#check_arity, create, execute, instance_each, list, load_commands, register_alias, register_command, require_commands_from_directory

Methods included from Output

#perror, #pinfo, #psystem, #ptable, #pwarn

Instance Method Details

#arityObject



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

def arity
  [nil, 0]
end

#descriptionObject



26
27
28
# File 'lib/mgit/commands/log.rb', line 26

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

#execute(_) ⇒ 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(_)
  Registry.chdir_each do |repo|
    repo.remote_tracking_branches.each do |branch, upstream|
      uc = repo.unmerged_commits(branch, upstream)
      next if uc.empty?

      pinfo "In repository #{repo.name}, branch #{upstream} the following commits were made:"

      t = []
      uc.each { |c| t << [c[:commit], c[:author], c[:subject]] }
      ptable t
    end
  end
end

#usageObject



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

def usage
  'log'
end