Git log --stat 每个项目文件

Git log --stat for every project file

我想要一些关于我的项目以及团队在过去几年所做工作的统计数据。我知道 git log --stat <file name> 可以为您提供一个日志,其中包含对该特定文件所做的所有修改。有没有办法在我的项目的每个文件上 运行 这个 git log --stat 并输出到一个文件?

谢谢。

在 git 中没有执行此操作的本机方法,但是有两个项目通过解析可能 git 命令的 git 命令来添加此功能。两者都被称为 git 名声,一个在 ruby 中实现,一个在 python 中实现。虽然它们被称为同一事物,但它们的功能集略有不同。

不是解析 git log,而是两者都解析 git blame 的结果,瓷器模式遍历通过 git ls-files 跟踪的所有文件。

Git Fame Python 示例输出:

Blame: 100%|███████████████████████████████████| 11/11 [00:00<00:00, 208.43it/s]
Total commits: 302
Total files: 37
Total loc: 3134
+----------------------+------+------+------+----------------+
| Author               |  loc | coms | fils |  distribution  |
+======================+======+======+======+================+
| Casper da Costa-Luis | 3123 |  297 |   35 | 99.6/98.3/85.4 |
| Not Committed Yet    |    7 |    4 |    2 |  0.2/ 1.3/ 4.9 |
| Evïan Etàcidñys      |    4 |    1 |    1 |  0.1/ 0.3/ 2.4 |
+----------------------+------+------+------+----------------+

Git Fame Ruby 示例输出:

Statistics based on master
Active files: 21
Active lines: 967
Total commits: 109

Note: Files matching MIME type image, binary has been ignored

+----------------+-----+---------+-------+---------------------+
| name           | loc | commits | files | distribution (%)    |
+----------------+-----+---------+-------+---------------------+
| Linus Oleander | 914 | 106     | 21    | 94.5 / 97.2 / 100.0 |
| f1yegor        | 47  | 2       | 7     |  4.9 /  1.8 / 33.3  |
| David Selassie | 6   | 1       | 2     |  0.6 /  0.9 /  9.5  |
+----------------+-----+---------+-------+---------------------+