Created
August 17, 2015 13:04
-
-
Save awwaiid/25ecfb45d48913f31f0e to your computer and use it in GitHub Desktop.
Git annotation including jira ticket key
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/ruby | |
# Add this to your .vimrc; then highlight lines and do ",ga" | |
# vmap ,ga :<C-U>!git blame -v -L <C-R>=line("'<")<CR>,<C-R>=line("'>")<CR> -e % \| jirablame <CR> | |
require 'date' | |
commit = {} | |
ticket = {} | |
ARGF.each do |line| | |
all, rev, author, d, code = *line.match(/^(.{8})\s+([^\s]+)\s+(.{25}) (.*)/) | |
# puts "GOT rev:#{rev} author:#{author} d:#{d} code:#{code}" | |
author.gsub!(/[(<>]/, '') | |
commit[rev] ||= `git log -n 1 #{rev}` | |
ticket[rev] ||= commit[rev].match(/[A-Z][A-Z]+-[0-9]+/) || '' | |
d = DateTime.parse(d).to_time.localtime.to_s[0,16] | |
puts "%-10s %8s %-20s %s %s" % [ticket[rev], rev, author, d, code] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment