Created
August 18, 2014 16:13
-
-
Save ryanflorence/1ae982f7e8189004582d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
verbose = ARGV[0] == '-v' | |
def colorize(text, color_code) | |
"\e[#{color_code}m#{text}\e[0m" | |
end | |
def red(text); colorize(text, 31); end | |
def green(text); colorize(text, 32); end | |
def bold(text); colorize(text, 33); end | |
types = {} | |
branches = `git branch`.split("\n").map { |b| b[2..b.length] } | |
branches.each do |branch| | |
change_id = `git log --grep='^Change-Id: ' #{branch} -1| grep 'Change-Id: '|head -n 1|\ | |
sed 's/Change-Id://'|sed 's/ //g'` | |
query = `ssh -p 29418 gerrit.instructure.com gerrit query #{change_id}` | |
status_match = query.match /status: (.+)/ | |
status = status_match ? status_match[1] : 'LOCAL' | |
(types[status] ||= []) << branch | |
ws = status.length > 8 ? "\t" : "\t\t" | |
status = red(status) if ['ABANDONED', 'MERGED'].include? status | |
status = green(status) if status == 'NEW' | |
message = status + ws + branch | |
puts message | |
if verbose | |
puts '--------' | |
puts query | |
end | |
end | |
puts | |
puts "Summary:" | |
puts "--------" | |
puts | |
types.each_with_index do |(k,v), branches| | |
puts bold(k) | |
v.each {|b| puts "\t#{b}"} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment