When using Git, blame shows 'committer' and not 'author'

Summary

When using Git, blame shows ‘committer’ and not ‘author’

Categories

  • ALM used: GitHub
  • CI system used: Github Actions (but not configured yet with our project)
  • Languages of the repository: Ruby, JS/TS
  • Only if the SonarCloud project is public, the URL: Not public, but happy to provide any necessary details privately

Steps to reproduce

Let me know if these steps don’t work and I’ll try to help. I am trying to make them as specific as possible.

  • Suppose you have two users, call them “Orion” and “Devin”.

  • As Orion, make two non-empty commits, to the main branch. Each commit writing to a separate file (we’re going to reorder these commits, so we don’t want merge conflicts).

  • Then push the branch upstream.

  • As Devin (from here on), pull latest changes from that branch

  • While at the HEAD of that branch, do an interactive rebase to swap the ordering of Orion’s two commits. This can be done from the terminal as follows:

    • git rebase -i HEAD~2.
    • Reorder the two commits in the editor by cutting and pasting line 1 to go below line 2.
    • Save the temporary file and the two commits will be in a different order.
  • Then push the branch upstream with a force push. git push -f <branch name>.

Devin will be the committer, Orion will be the author. SonarCloud shows the commiter and not the author as the blame result for each line. This is incorrect and probably a result of JGit’s implementation.

Potential workaround

None, except perhaps switching to SonarQube which isn’t an option for us

Impact

I think this is a big problem and it certainly keeps SonarCloud from being usable for us as a tool. The blame information is critically important as it can help with assigning remediation work and many of SonarCloud’s features use the blame information to provide context.

Solution

My best outsider’s guess on a potential solution would be for you to implement ‘native git’ in SonarCloud as it was done for SonarQube. [SONAR-16290] - Jira

Hopefully there’s an easier way to fix this, it is a potential show stopper.

Hi @MaximusMark

Thanks for reporting this issue: we acknowledge your concern is valid.
I am capturing it and will add it to our backlog so that this issue is addressed.

Regards,
@AlxO

1 Like

Any ETA? As I said, it’s a show stopper

Hi @MaximusMark,
No, there is no ETA on this one.

@AlxO Hi Alex, I just wanted to follow up to see if there had been any updates on this yet. Has it been worked on? Is it a priority? Thank you.

Hi @MaximusMark, the team is working on the issue at the moment. I’ll keep you posted.

1 Like

Hi @MaximusMark ,
We have rolled out a fix to production today. Would you want to test and confirm the behavior matches your expectations?
Thanks!
@AlxO

@AlxO Sorry for the delayed response. It seems to be a lot better now, but code that hasn’t been changed in a very long time still seems to have the problem. See commit d8a38e45b51680f68ed679f299da35596d31d986 on our bemaximusdotcom org, project maximus, in the file default_log.rb. It is not showing myself as the author there, but instead the person who merged the PR is shown as the author.

For now this seems good enough to be usable, though it would be appreciated if you could look into that when possible. Thank you very much!

It seems to occur even for some commits that are only a few months old, I am not sure what the pattern is. Maybe there is some kind of cache from before it was fixed?