Skip to content

Commit e306f07

Browse files
bobeaganNyholm
authored andcommitted
The Merge methods API is now official (#562)
* The Merge methods API is now official 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 * retain weird bool support for this value * let github throw errors instead * add back in $apiVersion to make it easier to handle preview versions 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 * throw invalidargumentexception when trying to use invalid merge method * add missing use
1 parent 63325b7 commit e306f07

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/Github/Api/PullRequest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Github\Api\PullRequest\Comments;
66
use Github\Api\PullRequest\Review;
77
use Github\Api\PullRequest\ReviewRequest;
8+
use Github\Exception\InvalidArgumentException;
89
use Github\Exception\MissingArgumentException;
910

1011
/**
@@ -29,7 +30,7 @@ class PullRequest extends AbstractApi
2930
*/
3031
public function configure($bodyType = null, $apiVersion = null)
3132
{
32-
if (!in_array($apiVersion, array('polaris-preview'))) {
33+
if (!in_array($apiVersion, array())) {
3334
$apiVersion = $this->client->getApiVersion();
3435
}
3536

@@ -41,7 +42,7 @@ public function configure($bodyType = null, $apiVersion = null)
4142
$bodyType .= '+json';
4243
}
4344

44-
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->client->getApiVersion(), $bodyType);
45+
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $apiVersion, $bodyType);
4546

4647
return $this;
4748
}
@@ -182,6 +183,10 @@ public function merge($username, $repository, $id, $message, $sha, $mergeMethod
182183
$mergeMethod = $mergeMethod ? 'squash' : 'merge';
183184
}
184185

186+
if (!in_array($mergeMethod, array('merge', 'squash', 'rebase'), true)) {
187+
throw new InvalidArgumentException(sprintf('"$mergeMethod" must be one of ["merge", "squash", "rebase"] ("%s" given).', $mergeMethod));
188+
}
189+
185190
$params = array(
186191
'commit_message' => $message,
187192
'sha' => $sha,

0 commit comments

Comments
 (0)