git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* My custom cccmd
@ 2009-10-15 13:20 Felipe Contreras
  2009-10-15 20:09 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Felipe Contreras @ 2009-10-15 13:20 UTC (permalink / raw)
  To: git

Hi,

I love the new option to run a cccmd and how good it works on the
linux kernel, but I couldn't find a generic script. So I decided to
write my own.

It's very simple, it just looks into the authors of the commits that
modified the lines being overridden (git blame). It's not checking for
s-o-b, or anything fancy.

Comments?

#!/usr/bin/env ruby

@commits = {} # keeps a count of commits per author

ARGV.each do |filename|
  File.open(filename) do |patch_file|
    patch_file.each_line do |patch_line|
      case patch_line
      when /^---\s+(\S+)/
        @source = $1[2..-1]
      when /^@@\s-(\d+),(\d+)/
        blame = `git blame -p -L #{$1},+#{$2} #{@source} | grep author`
        blame.each_line do |al|
          key, value = al.chomp.split(" ", 2)
          case key
          when "author"
            @name = value
          when "author-mail"
            @mail = value
            author = "\"#{@name}\" #{@mail}"
            @commits[author] ||= 0
            @commits[author] += 1
          end
        end
      end
    end
  end
end

@commits.each_key do |a|
  puts a
end

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-11-02 14:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-15 13:20 My custom cccmd Felipe Contreras
2009-10-15 20:09 ` Junio C Hamano
2009-10-15 21:37   ` Felipe Contreras
2009-10-25 15:04     ` Felipe Contreras
2009-10-27 21:53       ` Junio C Hamano
2009-10-30  8:39         ` Felipe Contreras
2009-10-30 21:52           ` Junio C Hamano
2009-11-02 14:25             ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).