Closed NikRam822 closed 3 weeks ago
Have you tried to do something like GHCommit.getCommitShortInfo().getAuthor()
?
Things are a bit messy on the GitHub REST API side and there are actually two authors, one at the root that is sometimes not resolved (maybe it's only resolved when there is a clear mapping with a user, I don't know), and the other that is raw from the commit info (the one I point above).
Yes, I tried using GHCommit.getCommitShortInfo().getAuthor(), but I noticed a strange behavior.
I'm developing a system to analyze GitHub projects (project link: https://github.com/NikRam822/TatMobileAnalyzer ). I'm reading all the commits of a GitHub project, pulling out the authors of the commits and collecting some statistics on each author. When using GHCommit.getCommitShortInfo().getAuthor(), some commits had a different author name than what is listed in the contributors section in GitHub.
For example: When analyzing this project: https://github.com/NikRam822/TatMobileAnalyzer using GHCommit.getCommitShortInfo().getAuthor(), I get the following authors:
Author 4 Amirka-Kh and 5 Amir are actually 1 author. The counterparts section in GitHub (https://github.com/NikRam822/TatMobileAnalyzer/graphs/contributors) has only these authors:
When using the getAuthor() method of the GHCommit class for this project, I get these authors:
These authors are correct and there are no duplicate authors, but when using GHCommit.getCommitShortInfo().getAuthor() "duplicates" appear.
Yeah, that’s expected. Short info provides you with the raw information in the Git repository. This information comes from local settings, not from GitHub. So people working on several machines might not always commit with the same information. Also people doing changes directly on GitHub.
Anyway, I don’t think there will be a silver bullet here, unfortunately.
Thanks, that makes more sense.
One last question before closing this issue) So there's no clear way to get the author block out of a commit?
"author": {
"name": "name",
"email": "name@mail.com",
"date": "2024-03-24T02:00:08Z"
},
@NikRam822
As @gsmet said, GHCommit.getCommitShortInfo().getAuthor()
is your best bet.
Interesting note:
This endpoint is where GHCommit
is pulled from: https://api.github.com/repos/NikRam822/GoOpenSource/commits/aa0bcf98d8a3a0e4eb7597720a87821c16537e9f
This endpoint is where GitCommit` is pulled from: https://api.github.com/repos/NikRam822/GoOpenSource/git/commits/aa0bcf98d8a3a0e4eb7597720a87821c16537e9f
But we don't currently support a getting GitCommit
separate from some parent like GHCommit
.
Describe the bug I use the getAuthor() method of the GHCommit class and get null, although the author of the commit is known. By querying https://api.github.com/repos/owner/repo/git/commits/commitSHA1 I get information about the author of the view as well:
To Reproduce Steps to reproduce the behavior: An example for my repository.
Expected behavior I expect to receive a GHUser object filled with author data.
Desktop :
Additional context