Skip to content

Instantly share code, notes, and snippets.

@awwaiid
Created August 17, 2015 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awwaiid/25ecfb45d48913f31f0e to your computer and use it in GitHub Desktop.
Save awwaiid/25ecfb45d48913f31f0e to your computer and use it in GitHub Desktop.
Git annotation including jira ticket key
#!/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