Skip to content

Instantly share code, notes, and snippets.

@CrashenX
Created March 14, 2012 12:36
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 CrashenX/2036192 to your computer and use it in GitHub Desktop.
Save CrashenX/2036192 to your computer and use it in GitHub Desktop.
git-cc script
#!/usr/bin/env ruby
@authors = {}
def parse_blame(line)
key, value = line.split(" ", 2)
case key
when "author"
@name = value
when "author-mail"
@mail = value
author = "\"#{@name}\" #{@mail}"
@authors[author] = true
end
end
ARGV.each do |filename|
patch_file = File.open(filename)
patch_file.each_line do |patch_line|
@from ||= patch_line[/From (\w+)/, 1]
case patch_line
when /^---\s+(\S+)/
@source = $1[2..-1]
when /^@@\s-(\d+),(\d+)/
blame = `git blame --incremental -L #{$1},+#{$2} #{@source} #{@from}^ | grep author`
blame.each_line { |l| parse_blame(l.chomp) }
end
end
end
@authors.each_key do |a|
puts a
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment