taylonr
taylonr

Reputation: 10790

See if someone has any code left in the git repository

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.

Upvotes: 5

Views: 110

Answers (2)

Daniel Klöck
Daniel Klöck

Reputation: 21147

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

Upvotes: 2

Andrew White
Andrew White

Reputation: 53516

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.

Upvotes: 1

Related Questions