Skip to content

Commit 4905606

Browse files
committed
Merge pull request #215 from mAAdhaTTah/feature/gist-commits
Add commits endpoint for Gists
2 parents a2f0e12 + cde103f commit 4905606

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

doc/gists.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ $gists = $github->api('gists')->all();
3333
$gist = $github->api('gists')->show(1);
3434
```
3535

36+
#### Get commits for a single gist
37+
38+
```php
39+
$commits = $github->api('gists')->commits(1);
40+
```
41+
3642
#### Create a gist
3743

3844
```php

lib/Github/Api/Gists.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public function update($id, array $params)
4444
return $this->patch('gists/'.rawurlencode($id), $params);
4545
}
4646

47+
public function commits($id)
48+
{
49+
return $this->get('gists/'.rawurlencode($id).'/commits');
50+
}
51+
4752
public function fork($id)
4853
{
4954
return $this->post('gists/'.rawurlencode($id).'/fork');

test/Github/Tests/Api/GistsTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ public function shouldShowGist()
5252
$this->assertEquals($expectedArray, $api->show(123));
5353
}
5454

55+
/**
56+
* @test
57+
*/
58+
public function shouldShowCommits()
59+
{
60+
$expectedArray = array('id' => '123');
61+
62+
$api = $this->getApiMock();
63+
$api->expects($this->once())
64+
->method('get')
65+
->with('gists/123/commits')
66+
->will($this->returnValue($expectedArray));
67+
68+
$this->assertEquals($expectedArray, $api->commits(123));
69+
}
70+
5571
/**
5672
* @test
5773
*/

0 commit comments

Comments
 (0)