>>> 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()
Update (July 11th, 2014)
I'm not sure what version i had installed when I first answered this question, but the latest version gave me an authors.html file when I ran gitstats /path/to/repo/.git /path/to/output/dir/ that contained exactly the info I was looking for.
It outputs the entire report with charts, navigation via tabs, etc.
Note: You cannot tell how many lines each user has contributed (at least with the version of gitstats that an apt-get install gitstats got me). The output was useful, and is a great way to learn about your code base and its contributors. I did the following, to get the number of lines of a particular user:
Then, I used Python to parse the data (since there were hundreds of commits):
>>> 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()
发布评论
评论(1)
更新(2014 年 7 月 11 日)
我不确定当我第一次回答这个问题时我安装了什么版本,但是当我运行
gitstats / 时,最新版本给了我一个
包含了我正在寻找的信息。authors.html
文件path/to/repo/.git /path/to/output/dir/原始答案
我发现这很简单。您只需键入:
它会输出带有图表、通过选项卡导航等的整个报告。
注意:您无法知道每个用户贡献了多少行(至少对于 apt-get install gitstats 的 gitstats 版本)代码> 明白了我)。输出很有用,是了解代码库及其贡献者的好方法。我执行了以下操作,以获取特定用户的行数:
然后,我使用 Python 来解析数据(因为有数百次提交):
Update (July 11th, 2014)
I'm not sure what version i had installed when I first answered this question, but the latest version gave me an
authors.html
file when I rangitstats /path/to/repo/.git /path/to/output/dir/
that contained exactly the info I was looking for.Original Answer
It's pretty simple, I found. You just type:
It outputs the entire report with charts, navigation via tabs, etc.
Note: You cannot tell how many lines each user has contributed (at least with the version of gitstats that an
apt-get install gitstats
got me). The output was useful, and is a great way to learn about your code base and its contributors. I did the following, to get the number of lines of a particular user:Then, I used Python to parse the data (since there were hundreds of commits):