Skip to content

The Merge methods API is now official #562

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

Merged
merged 6 commits into from
Apr 18, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/Github/Api/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,11 @@ class PullRequest extends AbstractApi
*
* @link https://developer.github.com/v3/pulls/#custom-media-types
* @param string|null $bodyType
* @param string|null $apiVersion
*
* @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. :(

public function configure($bodyType = null)
{
if (!in_array($apiVersion, array('polaris-preview'))) {
$apiVersion = $this->client->getApiVersion();
}

if (!in_array($bodyType, array('text', 'html', 'full', 'diff', 'patch'))) {
$bodyType = 'raw';
}
Expand Down Expand Up @@ -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?

$mergeMethod = 'merge';
}

$params = array(
'commit_message' => $message,
'sha' => $sha,
Expand Down