Skip to content

Commit

Permalink
feature #938 Add parameters to PullRequest commits method (seanmtaylor)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

Add a `$parameters` parameter to the `PullRequest::commits()` method to allow for pagination.

As per the docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls#list-commits-on-a-pull-request

Commits
-------

2069be2 Add parameters to PullRequest commits method
86b531f Add shouldShowCommitsFromPullRequestForPage
  • Loading branch information
seanmtaylor authored Nov 20, 2020
1 parent df653f3 commit 1831db1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Github/Api/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public function show($username, $repository, $id)
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$id);
}

public function commits($username, $repository, $id)
public function commits($username, $repository, $id, array $parameters = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/commits');
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/commits', $parameters);
}

public function files($username, $repository, $id, array $parameters = [])
Expand Down
16 changes: 16 additions & 0 deletions test/Github/Tests/Api/PullRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ public function shouldShowCommitsFromPullRequest()
$this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15'));
}

/**
* @test
*/
public function shouldShowCommitsFromPullRequestForPage()
{
$expectedArray = [['id' => 'id', 'sha' => '123123']];

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/ezsystems/ezpublish/pulls/15/commits', ['page' => 2, 'per_page' => 30])
->willReturn($expectedArray);

$this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15', ['page' => 2, 'per_page' => 30]));
}

/**
* @test
*/
Expand Down

0 comments on commit 1831db1

Please sign in to comment.