oro*_*aki 19 git code-statistics
我刚刚安装了GitStats,我就在那时我必须说,"现在,什么?".我在网站上看到了用户代码行等的示例,但没有关于如何获得这样简单统计数据的示例.我不需要图表或任何东西.我只是希望能够在一个用户列表中控制输出结果 - >代码行或其他东西.任何帮助深表感谢.
oro*_*aki 28
当我第一次回答这个问题时,我不确定我安装了什么版本,但最新版本authors.html
在运行时给了我一个文件,gitstats /path/to/repo/.git /path/to/output/dir/
其中包含我正在查找的信息.
我找到了,这很简单.你输入:
gitstats /path/to/the/repo.git --outputpath=directory_where_you_want_the_output
Run Code Online (Sandbox Code Playgroud)
它输出整个报告的图表,通过标签导航等.
注意:您无法分辨每个用户贡献了多少行(至少apt-get install gitstats
是我获得的gitstats版本).输出很有用,是了解代码库及其贡献者的好方法.我做了以下操作,以获取特定用户的行数:
git log --author="Some Author <Some.Author@example.com>" --oneline --shortstat > some_author.txt
Run Code Online (Sandbox Code Playgroud)
然后,我使用Python来解析数据(因为有数百次提交):
>>> import re
>>> file = open('some_author.txt', 'r')
>>> adds, dels = 0, 0
>>> for line in file.readlines():
... am, dm = re.search(r'\d+(?= insertions)', line), re.search(r'\d+(?= deletions)', line)
... if am is not None:
... adds += int(am.group())
... dels += int(dm.group())
...
>>> adds, dels
(5036, 1653)
>>> file.close()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14448 次 |
最近记录: |