class MGit::TagsCommand

Public Instance Methods

arity() click to toggle source
# File lib/mgit/commands/tags.rb, line 11
def arity
  [0, 0]
end
description() click to toggle source
# File lib/mgit/commands/tags.rb, line 19
def description
  'display the latest tag in repository (master branch)'
end
execute(_) click to toggle source
# File lib/mgit/commands/tags.rb, line 5
def execute(_)
  t = []
  Registry.each { |repo| t << print_latest_tag(repo) }
  ptable t, columns: [24, nil, nil]
end
usage() click to toggle source
# File lib/mgit/commands/tags.rb, line 15
def usage
  'tags'
end

Private Instance Methods

latest_tag(path) click to toggle source
# File lib/mgit/commands/tags.rb, line 27
def latest_tag(path)
  sc = System.git('describe --tags --abbrev=0 master', chdir: path)
  sc =~ /fatal:/ ? 'none' : sc.stdout.strip
end
latest_tag_time(path, tag) click to toggle source
# File lib/mgit/commands/tags.rb, line 32
def latest_tag_time(path, tag)
  Time.at(
    System.git("log -n 1 --format='%at' #{tag}", chdir: path)
      .stdout.strip.to_i
  ).strftime('%Y-%m-%d')
end
print_latest_tag(repo) click to toggle source