Skip to content

Commit 1616eb6

Browse files
committed
implemented PullRequests::commits (API 2.0)
1 parent db28bea commit 1616eb6

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

docs/repositories/pullrequests.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ $pull->update('gentle', 'secret-repo', 1, array(
5757
$pull->get($account_name, $repo_slug, 1);
5858
```
5959

60+
### Get the commits for a pull request:
61+
```php
62+
$pull->commits($account_name, $repo_slug, 1);
63+
```
64+
6065
----
6166

6267
#### Related:

lib/Bitbucket/API/Repositories/PullRequests.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,20 @@ public function get($account, $repo, $id)
145145
sprintf('repositories/%s/%s/pullrequests/%d', $account, $repo, $id)
146146
);
147147
}
148+
149+
/**
150+
* Get the commits for a pull request
151+
*
152+
* @access public
153+
* @param string $account The team or individual account owning the repository.
154+
* @param string $repo The repository identifier.
155+
* @param int $id ID of the pull request
156+
* @return MessageInterface
157+
*/
158+
public function commits($account, $repo, $id)
159+
{
160+
return $this->getClient()->setApiVersion('2.0')->get(
161+
sprintf('repositories/%s/%s/pullrequests/%d/commits', $account, $repo, $id)
162+
);
163+
}
148164
}

test/Bitbucket/Tests/API/Repositories/PullRequestsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,22 @@ public function testGetSpecificPullRequest()
152152

153153
$this->assertEquals($expectedResult, $actual);
154154
}
155+
156+
public function testGetCommitsForSpecificPullRequest()
157+
{
158+
$endpoint = 'repositories/gentle/eof/pullrequests/1/commits';
159+
$expectedResult = $this->fakeResponse(array('dummy'));
160+
161+
$client = $this->getHttpClientMock();
162+
$client->expects($this->once())
163+
->method('get')
164+
->with($endpoint)
165+
->will($this->returnValue($expectedResult));
166+
167+
/** @var \Bitbucket\API\Repositories\PullRequests $pull */
168+
$pull = $this->getClassMock('Bitbucket\API\Repositories\PullRequests', $client);
169+
$actual = $pull->commits('gentle', 'eof', 1);
170+
171+
$this->assertEquals($expectedResult, $actual);
172+
}
155173
}

0 commit comments

Comments
 (0)