From 6af803f4d9df06b06c31ebc907deb106df9c1e9b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 29 Sep 2010 19:29:54 +0200 Subject: add git-cc Signed-off-by: Florian Pritz --- git-cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 git-cc (limited to 'git-cc') diff --git a/git-cc b/git-cc new file mode 100755 index 0000000..1fb4d5c --- /dev/null +++ b/git-cc @@ -0,0 +1,33 @@ +#!/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 \ No newline at end of file -- cgit v1.2.3-24-g4f1b