Skip to content

Commit fe91371

Browse files
committed
Merge pull request KnpLabs#380 from Soullivaneuh/patch-3
Add merge by squash option
2 parents 6632c88 + 021d924 commit fe91371

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/Github/Api/PullRequest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,18 @@ public function merged($username, $repository, $id)
115115
return $this->get('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/merge');
116116
}
117117

118-
public function merge($username, $repository, $id, $message, $sha)
118+
public function merge($username, $repository, $id, $message, $sha, $squash = false, $title = null)
119119
{
120-
return $this->put('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/merge', array(
121-
'commit_message' => $message, 'sha' => $sha
122-
));
120+
$params = array(
121+
'commit_message' => $message,
122+
'sha' => $sha,
123+
'squash' => $squash,
124+
);
125+
126+
if (is_string($title)) {
127+
$params['commit_title'] = $title;
128+
}
129+
130+
return $this->put('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/merge', $params);
123131
}
124132
}

test/Github/Tests/Api/PullRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function shouldMergePullRequest()
143143
$api = $this->getApiMock();
144144
$api->expects($this->once())
145145
->method('put')
146-
->with('repos/ezsystems/ezpublish/pulls/15/merge', array('commit_message' => 'Merged something', 'sha' => str_repeat('A', 40)))
146+
->with('repos/ezsystems/ezpublish/pulls/15/merge', array('commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'squash' => false))
147147
->will($this->returnValue($expectedArray));
148148

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

0 commit comments

Comments
 (0)