This is more of a curiosity than a specific need, but my team has changed quite a bit over time. We've had to blow away some features that had been around for a while, and that got me wondering. Is there someway I could search the repo and see if there is any code left from user A.
I know I can do a git blame on particular file and see if User A has any lines in it, but is there a way I can do that on the entire repo?
Edit By "code left" I mean that User A wrote a line of code on Jan 1, 2010 and that line of code remains, unchanged, today.
Essentially, just like with git blame
where it shows the user's name next to the line, but on the entire repo instead of a single file.
This will print a list of all authors with the corresponding number of "owned" lines (excluding empty lines):
git ls-tree -r HEAD|cut -f 2|grep -E '\.(php|js|cc|h|cpp|hpp|c|txt|m)$' | xargs -n1 git blame --line-porcelain|grep "author "|sort|uniq -c|sort -nr
it currently matches php, js, cc, h, cpp, hpp, c, m and .txt file extensions.
Example output for the github repository UIView-Autolayout:
747 author liamnichols
458 author James Frost
356 author [email protected]
200 author Rich Turton
124 author Richard Turton
49 author Bart Vandendriessche
25 author Tom Guy
15 author David Keegan
14 author Rich Hodgkins
10 author Eric Horacek
10 author Bob Spryn
5 author Liam Nichols
2 author Nirvana Platform
1 author Gert Vanbeckevoort
We use gitinspector. Which can show how many lines a user "owns" and even show what files are most owned by a given user via the -r
option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With