[英]How to get file ownership i.e lines of code added by each developer per commit for an application
I tried below statement 我尝试了以下声明
git blame --line-porcelain file | git blame --line-porcelain文件| sed -n 's/^author //p' |sort | sed -n's / ^ author // p'|排序| uniq -c | uniq -c | sort -rn 排序-rn
but this statement gives for the latest commit . 但是该语句给出了最新的提交。 I need for each and every commit for a particular file. 我需要特定文件的每次提交。
Please suggest !! 请建议!
You can use this sequence 您可以使用此顺序
git log --reverse --oneline filename | awk '{ print $1; }'| while read c
do echo "authors for commit $c:"
git blame --line-porcelain filename $c | grep "^author " | sort | uniq -c | sort -nr
done
As I told you: This is a multi dimensional thing with coordinates (filename, commit, author, number of lines)
. 正如我告诉您的:这是一个具有坐标(filename, commit, author, number of lines)
多维事物。 First think about how you want to display or store the output. 首先考虑一下您要如何显示或存储输出。 Also note that git blame
is not about added lines but changed lines. 还要注意, git blame
不是关于添加的行,而是关于更改的行。 So if someone deleted a file with 10k lines, he/she will get noted as a changer of 10k lines, though the statement was just rm file
. 因此,如果某人删除了一个具有10k行的文件,尽管该语句只是rm file
,但他/她将被记录为10k行的rm file
。
Number of Lines changed is generally a very bad parameter to measure code or work done on some code. 更改的行数通常是衡量代码或对某些代码完成的工作的非常糟糕的参数。 Sometimes an author that thinks a week over his code and then changes one line, improving the speed of the program by a factor of 1000 is a much worthier author than this guy last week, who wrote 5000 lines of spagetthi code. 有时候,一个写作者考虑一周的代码然后更改一行代码,从而将程序速度提高1000倍的作者,比上个星期写了5000行spagetthti代码的那个家伙要有价值得多。
But this information is redundant. 但是这些信息是多余的。 Better use 更好地使用
git log -p --reverse filename
and learn to read patch files. 并学习阅读补丁文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.