-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add support for merge method and repository squash settings. #446
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -253,12 +253,16 @@ type PullRequestMergeResult struct { | |
|
|
||
| // PullRequestOptions lets you define how a pull request will be merged. | ||
| type PullRequestOptions struct { | ||
| Squash bool | ||
| CommitTitle string | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't these be *string? Or should we check for
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I can tell from https://developer.github.com/changes/2016-09-26-pull-request-merge-api-update/ and https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by removing this any user of our library who is doing will be unable to compile. We "could" keep supporting them by automatically turning
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, GitHub is changing their API.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But we don't have to. We may decide we want to, and that's fine. But it is easy to write: And then inside https://github.com/google/go-github/pull/446/files#diff-aafac035cce1f6a65b02566c5345b805R276 Just pointing it out. I'm actually ok dropping OUR legacy API and break compile for our users. But its also pretty easy to be a friendly library if that's the path we wish to take.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm... @willnorris and @shurcooL - what are your thoughts about breaking the current (preview) API involving "squashes" when the GitHub Preview API itself is changing? Do we match the GitHub API or do we attempt to retain a "more friendly" API toward squashes? To remain consistent with the rest of this package, I'm leaning toward matching the GitHub API as close as possible to not create any surprises for users. But if you feel we should depart from this consistency and make the API friendlier for squashing, I'm not adverse to that either.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just caught up on this thread. I'll standby until we settle on what this API should have. Please feel free to ping me so I can make the appropriate changes. Thanks for all of the comments!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We've had this discussion in the past. Let me try to find it. I think it's this comment and its thread that I had in mind. Basically, my POV is that we're welcome to make breaking API changes to endpoints that are in preview. We absolutely should, that's the whole point of API preview period, it lets GitHub iterate on the API and this library should follow. Using the very first iteration is going to be counter-productive for users after the API exits preview period. @gmlewis I'm not sure if your question is about whether it's okay to break go-github APIs for preview endpoints (IMO it is), or if it's about whether we should deviate from GitHub API in what go-github provides (IMO we should try to stay close, but still be idiomatic Go, no need to compromise on usability/friendliness).
I think your question is about the latter. Can you elaborate on what 2 alternatives you're considering here? Also, we should open an issue that this PR resolves and continue the discussion there. It's hard to see this "outdated comment" in this PR.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating new issue for discussion, now that GitHub no longer appears to be under DDOS attack. |
||
|
|
||
| // The merge method to use. Possible values include: "merge", "squash", and "rebase" with the default being merge. | ||
| MergeMethod string | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please document this field? |
||
| } | ||
|
|
||
| type pullRequestMergeRequest struct { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will need to add |
||
| CommitMessage *string `json:"commit_message"` | ||
| Squash *bool `json:"squash,omitempty"` | ||
| CommitTitle *string `json:"commit_title,omitempty"` | ||
| MergeMethod *string `json:"merge_method,omitempty"` | ||
| } | ||
|
|
||
| // Merge a pull request (Merge Button™). | ||
|
|
@@ -269,7 +273,8 @@ func (s *PullRequestsService) Merge(owner string, repo string, number int, commi | |
|
|
||
| pullRequestBody := &pullRequestMergeRequest{CommitMessage: &commitMessage} | ||
| if options != nil { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And update this section too. |
||
| pullRequestBody.Squash = &options.Squash | ||
| pullRequestBody.CommitTitle = &options.CommitTitle | ||
| pullRequestBody.MergeMethod = &options.MergeMethod | ||
| } | ||
| req, err := s.client.NewRequest("PUT", u, pullRequestBody) | ||
|
|
||
|
|
||
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.
Could you please add
CommitTitleto this struct?https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
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.
Yes, I certainly missed that in the blog post.