felipec (owner)

Revisions

gist: 218093 Download_button fork
public
Description:
git-cc script
Public Clone URL: git://gist.github.com/218093.git
Embed All Files: show embed
git-cc #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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