When fetching a commit, the commit author struct does not populate the login field as expected. It looks like the Login field is populated under the username json key only for webhooks: https://github.com/google/go-github/blob/master/github/git_commits.go#L53
The inconsistent naming is referred to in: https://github.com/google/go-github/issues/605#issuecomment-323763728
What do you guys think of adding a new field in the CommitAuthor struct called Username which populates from username, and change the Login field to use the login field?
I'm confused. I'm trying to find examples in the GitHub documentation to support the addition of the login field to the CommitAuthor struct.
I'm looking here:
https://developer.github.com/v3/activity/events/types/
and searching for "author" and get 11 hits.
Hits 7 and 8 show:
"author": {
"name": "baxterthehacker",
"email": "[email protected]",
"username": "baxterthehacker"
},
Hits 9 and 11 are not a CommitAuthor ... but are part of ReleaseEvent and StatusEvent, respectively.
Hit 10 is:
"author": {
"name": "baxterthehacker",
"email": "[email protected]",
"date": "2015-05-05T23:40:12Z"
},
So I'm having troubles understanding this issue.
Can you please point me to examples in the GitHub API docs that justify these changes?
The login field I am trying to populate is under the author entry inside the commits API: https://developer.github.com/v3/repos/commits/
The original Login field was added as part of a larger change to support the username field in webhooks. I'm not sure why Github uses username in webhooks but login in their commit APIs, but that's the inconsistency I'm trying to resolve.
The login field I am trying to populate is under the
authorentry inside the commits API: https://developer.github.com/v3/repos/commits/
That would map to RepositoryCommit, which has Author *User field, and User has Login string field.
See https://godoc.org/github.com/google/go-github/github#RepositoriesService.GetCommit, it returns *RepositoryCommit type, not *Commit.
When I do a GetCommit, the return type is a *Commit: https://github.com/google/go-github/blob/master/github/git_commits.go#L63
Does that mean I need to cast to a RepositoryCommit?
I need to use Repositories.GetCommit instead of Git.GetCommit.
It sounds like you're confusing Git Service (https://godoc.org/github.com/google/go-github/github#GitService) with Repository Service (https://godoc.org/github.com/google/go-github/github#RepositoryService).
Earlier, you said:
The login field I am trying to populate is under the
authorentry inside the commits API: https://developer.github.com/v3/repos/commits/
That maps to https://godoc.org/github.com/google/go-github/github#RepositoriesService.GetCommit method, not https://godoc.org/github.com/google/go-github/github#GitService.GetCommit method.
Thanks for the help!
No problem.