刚刚意识到,如果您在* nix / OS X中--name-only
使用文件名将漂亮的格式打印为空字符串,并使用此方法对提交的最高次数进行排序,唯一化和排序,则可以使用:
git log --name-only --author=John --pretty=format: | sort | uniq -c | sort -nr
确保使用的作者合适。
例如,如果我们尝试在Rails中寻找DHH的作者,则可以这样做:
git log --format='%aN <%aE>' | LC_ALL='C' sort -u | grep avid
并注意DHH在Rails git repo中的所有作者都使用了“ David Heinemeier Hansson”这个名字。因此,我们可以这样做:
git log --name-only --author="David Heinemeier Hansson" --pretty=format: | sort | uniq -c | sort -nr
可能输出:
3624
611 actionpack/CHANGELOG
432 activerecord/CHANGELOG
329 railties/CHANGELOG
206 activerecord/lib/active_record/base.rb
195 activesupport/CHANGELOG
157 actionpack/lib/action_controller/base.rb
153 railties/Rakefile
108 activerecord/lib/active_record/associations.rb
79 actionpack/lib/action_view/helpers/javascript_helper.rb
75 activerecord/lib/active_record/validations.rb
74 activerecord/test/base_test.rb
69 actionmailer/CHANGELOG
66 railties/lib/rails_generator/generators/applications/app/app_generator.rb
66 activerecord/Rakefile
66 actionpack/lib/action_controller/caching.rb
60 actionpack/lib/action_controller/routing.rb
59 railties/lib/initializer.rb
59 actionpack/Rakefile
57 actionpack/lib/action_controller/request.rb
...
因此,截至2015年2月21日,Rails git回购中有3624个文件,看来他从未亲自提交过该文件,该文件的最大提交数量是ActionPack CHANGELOG,共611次提交,其次是ActiveRecord CHANGELOG ,而ActiveRecord :: Base是他提交最多的Ruby文件。
如果要从计数中排除未触及的文件数,请使用--format=
代替--pretty=format:
,例如:
git log --name-only --author="David Heinemeier Hansson" --format: | sort | uniq -c | sort -nr
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句