visevol / GithubVisualisation

PFE028 Été 2024
MIT License
0 stars 1 forks source link

[Backend] `SourceFile#main_contributor` shows a different result than git log #53

Open zergov opened 12 hours ago

zergov commented 12 hours ago

Running #main_contributor on a SourceFile returns a different result than asking git directly:

I was inspecting the result for the file activejob/lib/active_job.rb in rails.

This is what we get from our API: image

This is what we get when we ask Git

➜  rails git:(main) git log --no-merges --pretty=format:"%aN" activejob/lib/active_job.rb | sort | uniq -c | sort -r
      4 Rafael Mendonça França
      4 Abdelkader Boudih
      3 Petrik
      2 zzak
      2 Sam Bostock
      2 Ryuta Kamizono
      2 Jean Boussier
      2 Arun Agrawal
      2 Akira Matsuda
      1 ksss
      1 fatkodima
      1 alpaca-tc
      1 Yoshiyuki Hirano
      1 Xavier Noria
      1 Rashmi Yadav

Git says Ryuta Kamizono authored 2 commits on that file, but we say 7. Specifically, these 7 commits:

cb0fdaacb277bd0595bfd73178329922aa24477e
785427b88c01654a441b8a7ed602feb35358285b
2b0b5a75c03d597acfe18c2cd7ac6185732797b2   <-- non merge commit
afc79e3cb0906d06b035ef30411c44ddc2132409
65766ebcc85dca0a777bf3a114a906b43f0bdca6   <-- non merge commit
b7e1ea2eeb524224dc06c08fbb779f99d20dde2f
e6486076f066e4ce6b7e7e8270d54f42667a5075

I think Git don't count merge commits. This makes sense, the person that merges a pull request is not necessarily the author of the thing being merged.

We should do the same, and don't count merge commits when computing the main contributor of a file.