Created
January 16, 2013 17:50
-
-
Save chetan/4549183 to your computer and use it in GitHub Desktop.
show the last commit for all branches
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 | |
branches = `git branch -a` | |
exit 1 if $?.to_i != 0 | |
branches = branches.split(/\n/).map{ |b| b.gsub(/(\*|\->.*$|^\s+| +$)/, '') }; | |
l = branches.max_by{ |b| b.length }.length | |
branches.each do |branch| | |
pad = " " * (l-branch.length) | |
STDOUT.write("#{pad}#{branch} ") | |
format = [ | |
"%Cred%h%Creset - ", # commit | |
"%Cgreen(%cr)", # age | |
"%Creset %s ", # log | |
"%C(bold blue)<%an>", # user | |
"%C(yellow)%d", # branch info | |
"%Creset" # reset | |
].join("") | |
system("git --no-pager log -1 --color --pretty=format:'#{format}' --abbrev-commit #{branch}") | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment