jobwat
7/16/2013 - 12:20 AM

grep-git-logs-TMs.rb


Dir.chdir "/home/vagrant/app"
logs = `git log --pretty 1.2.0..1.2.1 | grep -E "(T ?M[-_ ]?[0-9]+|T ?T[-_ ]?[0-9]+)"`
labels = logs.each_line.map do |line|
  line.scan(/T ?[TM][-_ ]?[0-9]+/i).map do |s|
    s.upcase.gsub(/T ?([TM])[^\d]?(\d+)/, 'T\1-\2')
  end
end
final_list = labels.sort.uniq{|s|s.first}

final_list.each do |item|
  puts item.inspect
end

# # get last tag version
#
# git describe --abbrev=0 --tags
#
# # http://stackoverflow.com/questions/1404796/how-to-get-the-latest-tag-name-in-current-branch-in-git