Created
March 14, 2012 12:36
-
-
Save CrashenX/2036192 to your computer and use it in GitHub Desktop.
git-cc script
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 | |
@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