Skip to content
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

The Merge methods API is now official #562

Merged
merged 6 commits into from
Apr 18, 2017

Conversation

bobeagan
Copy link
Contributor

@bobeagan bobeagan commented Apr 7, 2017

see: https://developer.github.com/changes/2017-04-07-end-merge-methods-api-preview/
this removes the apiVersion (that wasn't being used anyway..)
also adds support for rebase mergeMethod per https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button

see: https://developer.github.com/changes/2017-04-07-end-merge-methods-api-preview/
this removes the apiVersion (that wasn't being used anyway..)
also adds support for rebase mergeMethod per https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button

Since this previously looked for the value to be bool, this is a breaking change
@bobeagan
Copy link
Contributor Author

bobeagan commented Apr 7, 2017

I could technically update this PR to not be breaking, just seems really weird to me to randomly have a mixed string/bool value used here

@Nyholm
Copy link
Collaborator

Nyholm commented Apr 8, 2017

I could technically update this PR to not be breaking, just seems really weird to me to randomly have a mixed string/bool value used here

It is weird, I do agree with you. But we should keep BC. Though, we should document this to make sure we fix it before next major release.

@@ -163,6 +158,10 @@ public function merge($username, $repository, $id, $message, $sha, $mergeMethod
$mergeMethod = $mergeMethod ? 'squash' : 'merge';
}

if (!in_array($mergeMethod, array('squash', 'rebase'))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎 We should let GitHub's API throw an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine but there are several other places throughout the codebase that behave in this way already, just do a search for in_array to see what I mean. Should an issue be opened to remove all of those checks in the next major version for consistency?

@bobeagan
Copy link
Contributor Author

@Nyholm @GrahamCampbell just checking back in on this to see if you do want me to make the requested change (even though plenty of other places in the codebase already follow that pattern).

@GrahamCampbell
Copy link
Contributor

I think it should be changed here, regardless of the other classes.

@GrahamCampbell
Copy link
Contributor

Otherwise, someone could write sqash by mistake, and never no, because the package silently changes it to merge.

@Nyholm
Copy link
Collaborator

Nyholm commented Apr 14, 2017

Thank you both. I did not reflect on this. I've done some digging:

@bobeagan you are correct, that is the pattern we usually do. However, we do it for reading data. When we write we throw an exception. See https://github.com/KnpLabs/php-github-api/blob/2.2.0/lib/Github/Api/PullRequest/Review.php#L120

I think we should throw exception even for reading data, but that is BC... (I'll written an issue (#566))

I think you should throw an exception here.

*
* @return self
*/
public function configure($bodyType = null, $apiVersion = null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though removing this is not breaking BC, I think we should keep it. Because if we remove it and then later adds another optional parameter to this function, that WILL be BC and it is really hard to keep track of.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case I'll need to fix it since I realized when I was removing it that I never actually used the $apiVersion variable when setting the accept header value. :(

…in the future

there are no preview versions now so checking against an empty array
also had to fix the acceptHeaderValue to correctly use the variable
@bobeagan
Copy link
Contributor Author

@Nyholm and @GrahamCampbell updated and ready for another look

@bobeagan bobeagan mentioned this pull request Apr 14, 2017
@Nyholm
Copy link
Collaborator

Nyholm commented Apr 18, 2017

Thank you

@Nyholm Nyholm merged commit e306f07 into KnpLabs:master Apr 18, 2017
@bobeagan bobeagan deleted the pr-merge-method-official branch April 18, 2017 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants