Created
January 10, 2013 00:48
-
-
Save levity/4498428 to your computer and use it in GitHub Desktop.
list remote branches sorted by age
This file contains hidden or 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
require 'date' | |
branch_times = `git remote show origin`.split("\n").grep(/tracked/).map do |line| | |
name = line.split(' ').first | |
last_log = `git log -n1 origin/#{name}` | |
last_time = Date.parse(last_log.split("\n").grep(/^Date/).first.sub(/^Date\s+/, '')) | |
[name, last_time.to_date] | |
end.sort_by(&:last) | |
branch_name_maxlen = branch_times.map(&:first).map(&:size).max | |
branch_times.each do |name, date| | |
puts "%-#{branch_name_maxlen}s #{date}" % name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment