Skip to content

Commit 40321ec

Browse files
committed
Missing gist revision api endpoint
1 parent d189dbd commit 40321ec

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
@@ -37,6 +37,12 @@ $gists = $github->api('gists')->all();
3737
$gist = $github->api('gists')->show(1);
3838
```
3939

40+
#### Get a specific revision of a gist
41+
42+
```php
43+
$gist = $github->api('gists')->show(1, 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce');
44+
```
45+
4046
#### Get commits for a single gist
4147

4248
```php

lib/Github/Api/Gists.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public function show($number)
5151
return $this->get('/gists/'.rawurlencode($number));
5252
}
5353

54+
public function revision($number, $sha)
55+
{
56+
return $this->get('/gists/'.rawurlencode($number).'/'.rawurlencode($sha));
57+
}
58+
5459
public function create(array $params)
5560
{
5661
if (!isset($params['files']) || (!is_array($params['files']) || 0 === count($params['files']))) {

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 shouldShowGistWithSpecificReference()
59+
{
60+
$expectedArray = ['id' => '123', 'sha' => 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce'];
61+
62+
$api = $this->getApiMock();
63+
$api->expects($this->once())
64+
->method('get')
65+
->with('/gists/123/d189dbd4c5d96442db74ebcb62bb38e661a0c8ce')
66+
->will($this->returnValue($expectedArray));
67+
68+
$this->assertEquals($expectedArray, $api->revision(123, 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce'));
69+
}
70+
5571
/**
5672
* @test
5773
*/

0 commit comments

Comments
 (0)