-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix GetBranch response #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
You're absolutely right. It was surprising to me that we'd have such a glaring error, so I dug through git blame to see how it occurred (in order to make sure I'm not overlooking something). It seems we've had the issue since its very initial implementation in 2014. From that commit, I have a pretty good of how it happened. If you look at https://developer.github.com/v3/repos/branches/#list-branches, you'll see the example that the list endpoint provides has only "sha" and "url" fields inside the "commit" object. A coincidence is that both
Thanks for the patch! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -457,7 +457,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) { | |||
|
|||
want := &Branch{ | |||
Name: String("n"), | |||
Commit: &Commit{SHA: String("s")}, | |||
Commit: &RepositoryCommit{SHA: String("s")}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good, but I think it's a good opportunity to expand the test data to include a Commit
inside. That way it'd be a little more representative of the real data you get from GitHub, ala https://developer.github.com/v3/repos/branches/#get-branch.
Something like this:
want := &Branch{
Name: String("n"),
Commit: &RepositoryCommit{
SHA: String("s"),
Commit: &Commit{
Message: String("m"),
},
},
Protected: Bool(true),
}
You'd have to update the mux.HandleFunc("/repos/o/r/branches/b"
above, of course.
Doing this is optional, if you agree it'd be an improvement for this Go package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I’ve done it: 7920789
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
Included in a77ccc9. |
Closes google#490. Change-Id: Ie12aca585fe07cb572b347ef3b8f42c26b229808
I want to get a time of the last commit in branch. I read Github API: Get Branch docs and found the RepositoriesService.GetBranch method. I called it like so:
But get the following data (e.g. for this repo):
As you see, the Author and Committer fields has no info. I tried to call the endpoint with curl:
And get data I expected:
Looks like
commit
at the root of response is a RepositoryCommit.