diff --git a/doc/gists.md b/doc/gists.md index 9cbfb0a1624..604ee142344 100644 --- a/doc/gists.md +++ b/doc/gists.md @@ -33,6 +33,12 @@ $gists = $github->api('gists')->all(); $gist = $github->api('gists')->show(1); ``` +#### Get commits for a single gist + +```php +$commits = $github->api('gists')->commits(1); +``` + #### Create a gist ```php diff --git a/lib/Github/Api/Gists.php b/lib/Github/Api/Gists.php index 7514d99e6ff..ffdc5e3201e 100644 --- a/lib/Github/Api/Gists.php +++ b/lib/Github/Api/Gists.php @@ -44,6 +44,11 @@ public function update($id, array $params) return $this->patch('gists/'.rawurlencode($id), $params); } + public function commits($id) + { + return $this->get('gists/'.rawurlencode($id).'/commits'); + } + public function fork($id) { return $this->post('gists/'.rawurlencode($id).'/fork'); diff --git a/test/Github/Tests/Api/GistsTest.php b/test/Github/Tests/Api/GistsTest.php index 1ba6a8c7386..fb231016b75 100644 --- a/test/Github/Tests/Api/GistsTest.php +++ b/test/Github/Tests/Api/GistsTest.php @@ -52,6 +52,22 @@ public function shouldShowGist() $this->assertEquals($expectedArray, $api->show(123)); } + /** + * @test + */ + public function shouldShowCommits() + { + $expectedArray = array('id' => '123'); + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('gists/123/commits') + ->will($this->returnValue($expectedArray)); + + $this->assertEquals($expectedArray, $api->commits(123)); + } + /** * @test */