Skip to content

Commit cb34b34

Browse files
committed
implemented Repository::forks (API 2.0)
1 parent 9762844 commit cb34b34

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

docs/repositories/repository.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@ $repo->update($account_name, $repo_slug, array(
5050
$repo->delete($account_name, $repo_slug);
5151
```
5252

53-
### Gets the list of accounts watching a repository: (API 2.0)
53+
### Get the list of accounts watching a repository: (API 2.0)
5454
```php
5555
$repo->watchers($account_name, $repo_slug);
5656
```
5757

58+
### Get the list of repository forks: (API 2.0)
59+
```php
60+
$repo->forks($account_name, $repo_slug);
61+
```
62+
5863
### Fork a repository:
5964
```php
6065
$repo->fork($account_name, $repo_slug, $fork_slug, array(

lib/Bitbucket/API/Repositories/Repository.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,21 @@ public function watchers($account, $repo)
158158
);
159159
}
160160

161+
/**
162+
* Gets the list of repository forks.
163+
*
164+
* @access public
165+
* @param string $account The team or individual account owning the repository.
166+
* @param string $repo The repository identifier.
167+
* @return MessageInterface
168+
*/
169+
public function forks($account, $repo)
170+
{
171+
return $this->getClient()->setApiVersion('2.0')->get(
172+
sprintf('repositories/%s/%s/forks', $account, $repo)
173+
);
174+
}
175+
161176
/**
162177
* Fork a repository
163178
*

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ public function testGetRepositoryWatchers()
140140
$this->assertEquals($expectedResult, $actual);
141141
}
142142

143+
public function testGetRepositoryForks()
144+
{
145+
$endpoint = 'repositories/gentle/eof/forks';
146+
$expectedResult = $this->fakeResponse(array('dummy'));
147+
148+
$client = $this->getHttpClientMock();
149+
$client->expects($this->once())
150+
->method('get')
151+
->with($endpoint)
152+
->will($this->returnValue($expectedResult));
153+
154+
/** @var \Bitbucket\API\Repositories\Repository $repo */
155+
$repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client);
156+
$actual = $repo->forks('gentle', 'eof');
157+
158+
$this->assertEquals($expectedResult, $actual);
159+
}
160+
143161
public function testForkRepositorySuccess()
144162
{
145163
$endpoint = 'repositories/gentle/eof/fork';

0 commit comments

Comments
 (0)