Find which developers' code was changed by a commit?

215 Views Asked by At

Is there a way using git to find out which developers' code was changed by a particular commit?

The process would look something like: Take a commit SHA, get each changed line in the parent commit git diff SHA^!, group them by the author of the line (git blame) and then order them by number of lines and list it out like

Commit SHA### updated code written by the following developers:
Jane Smythe (23 lines)
Rickard Strauss (8 lines)

I am thinking of using this to print to the console when committing (the following devs code were modified, make sure to tag them in your PR), it could even be potentially integrated with Bitbucket/Git to automatically tag devs whose code is being changed or email them etc etc.

I found this gist using python that appears to do something similar, but is going into a separate language other than bash/git necessary for this?

2

There are 2 best solutions below

0
On

You could use git-diff-blame https://github.com/dmnd/git-diff-blame

And you could filter by commit sha

5
On

It is not possible to do that reliably, because git would need to distinguish between added and edited lines which doesn't work.

A good approach would be to take the percentage of contributions in the file - before the commit - and address those in the PR which contributed most. This is what github is doing btw.