3 ## git-rank-contributors: a simple script to trace through the logs and
4 ## rank contributors by the total size of the diffs they're responsible for.
5 ## A change counts twice as much as a plain addition or deletion.
7 ## Output may or may not be suitable for inclusion in a CREDITS file.
8 ## Probably not without some editing, because people often commit from more
11 ## git-rank-contributors Copyright 2008 William Morgan <wmorgan-git-wt-add@masanjin.net>.
12 ## This program is free software: you can redistribute it and/or modify
13 ## it under the terms of the GNU General Public License as published by
14 ## the Free Software Foundation, either version 3 of the License, or (at
15 ## your option) any later version.
17 ## This program is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ## GNU General Public License for more details.
22 ## You can find the GNU General Public License at:
23 ## http://www.gnu.org/licenses/
26 def obfuscate
; gsub(/@/, " at the ").gsub(/\.(\w+)(>|$)/, ' dot \1s\2') end
30 verbose
= ARGV.delete("-v")
31 obfuscate
= ARGV.delete("-o")
35 `git log -p --no-color`.each
do |l
|
37 when (state
== :pre_author || state
== :post_author) && l
=~
/Author: (.*)$/
41 when state
== :post_author && l
=~
/^\+\+\+/
43 when state
== :in_diff && l
=~
/^[\+\-]/
45 when state
== :in_diff && l
=~
/^commit /
50 lines
.sort_by
{ |a
, c
| -c
}.each
do |a
, c
|
51 a
= a
.obfuscate
if obfuscate
53 puts
"#{a}: #{c} lines of diff"