What have you found for these years?

2009-06-11

git log --shortstat

updated: 增加其他統計,不過好難一次統計好... 可能要再試試

我最愛(寫)one-liner. 寫法是用 irb 慢慢串 method, 不難

   1  $stdin.read.scan(/.*\n\n.*/).map{|i|i=~/(.*)\n\n (\d+).*(\d+).*(\d+)/;[$1,$2,$3,$4]}.inject(Hash.new([0]*3)){|h,i|h[i.first]=i[1..-1].map(&:to_i).zip(h[i.first]).map{|n|n.inject(0,&:+)};h}.each{|k,v|printf "%12s changed %4d files, inserted %4d lines, deleted %4d lines.\n",k,*v

godfat ~/p/g/photos> git log --pretty=tformat:%an --shortstat --no-merges | ruby1.9 -e '$stdin.read.scan(/.*\n\n.*/).map{|i|i=~/(.*)\n\n (\d+).*(\d+).*(\d+)/;[$1,$2,$3,$4]}.inject(Hash.new([0]*3)){|h,i|h[i.first]=i[1..-1].map(&:to_i).zip(h[i.first]).map{|n|n.inject(0,&:+)};h}.each{|k,v|printf "%12s changed %4d files, inserted %4d lines, deleted %4d lines.\n",k,*v}'
Lin Jen-Shin changed  892 files, inserted  925 lines, deleted  855 lines.
unknown changed 193 files, inserted 317 lines, deleted 327 lines.
godfat changed 5156 files, inserted 3635 lines, deleted 3541 lines.
charlesc changed 519 files, inserted 961 lines, deleted 960 lines.
scrazy changed 528 files, inserted 237 lines, deleted 177 lines.
wang changed 515 files, inserted 947 lines, deleted 824 lines.
root changed 1891 files, inserted 284 lines, deleted 210 lines.

godfat ~/p/g/photos> git shortlog -s
   381  Lin Jen-Shin
329 charlesc
1445 godfat
143 photos
98 root
90 scrazy
124 unknown
397 wang

計算 git log title 的 wc, 去除 git-svn-id 等等
(wc 是 lines, words, bytes. 然後這邊用 binary 去算是因為,
裡面有一個 message subject 是一堆亂碼,可能是 big5?
然後由於抓不出 body, 所以只能算 subject 長度... 我好幾個
可是有寫滿長的 commit log body, 這樣算不出來 @@)

godfat ~/p/g/photos> git shortlog --no-merges | ruby1.9 -e '$stdin.read.force_encoding("binary").gsub(/[ ]+git-svn-id:.*/, "").squeeze("\n").scan(/(.* \(\d+\):\n([ ]+.*\n)*)/).each{|i|i.first.lines.to_a.tap{|l|IO.popen("wc","r+"){|wc|wc.write(l[1..-1].join);wc.close_write;printf "%12s %s",l.first,wc.read}}}'
Lin Jen-Shin (331):
331 2189 15676
charlesc (319):
319 599 5586
godfat (1180):
1180 9345 67739
root (98):
47 224 1653
scrazy (90):
89 339 2801
unknown (117):
117 236 2121
wang (397):
36 191 1345

0 retries:

Post a Comment

All texts are licensed under CC Attribution 3.0