Skip to content

Commit

Permalink
Merge pull request #380 from Soullivaneuh/patch-3
Browse files Browse the repository at this point in the history
Add merge by squash option
  • Loading branch information
cursedcoder committed May 29, 2016
2 parents 6632c88 + 021d924 commit fe91371
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions lib/Github/Api/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,18 @@ public function merged($username, $repository, $id)
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/merge');
}

public function merge($username, $repository, $id, $message, $sha)
public function merge($username, $repository, $id, $message, $sha, $squash = false, $title = null)
{
return $this->put('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/merge', array(
'commit_message' => $message, 'sha' => $sha
));
$params = array(
'commit_message' => $message,
'sha' => $sha,
'squash' => $squash,
);

if (is_string($title)) {
$params['commit_title'] = $title;
}

return $this->put('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/merge', $params);
}
}
2 changes: 1 addition & 1 deletion test/Github/Tests/Api/PullRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function shouldMergePullRequest()
$api = $this->getApiMock();
$api->expects($this->once())
->method('put')
->with('repos/ezsystems/ezpublish/pulls/15/merge', array('commit_message' => 'Merged something', 'sha' => str_repeat('A', 40)))
->with('repos/ezsystems/ezpublish/pulls/15/merge', array('commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'squash' => false))
->will($this->returnValue($expectedArray));

$this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40)));
Expand Down

0 comments on commit fe91371

Please sign in to comment.