Skip to content

Commit c861336

Browse files
Alexander Viktorkinvimishor
Alexander Viktorkin
authored andcommitted
Merged in sancho67/bitbucket-api/fix_api2_tags (pull request #47)
Updated get tags to API 2.0
1 parent 2df10c7 commit c861336

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lib/Bitbucket/API/Repositories/Repository.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,18 @@ public function manifest($account, $repo, $revision)
249249
}
250250

251251
/**
252-
* Get a list of tags
252+
* Get a pagination list of tags or tag object by name
253253
*
254254
* @access public
255255
* @param string $account The team or individual account owning the repository.
256256
* @param string $repo The repository identifier.
257+
* @param string $name The name of the tag
257258
* @return MessageInterface
258259
*/
259-
public function tags($account, $repo)
260+
public function tags($account, $repo, $name = '')
260261
{
261-
return $this->requestGet(
262-
sprintf('repositories/%s/%s/tags', $account, $repo)
262+
return $this->getClient()->setApiVersion('2.0')->get(
263+
sprintf('repositories/%s/%s/refs/tags/%s', $account, $repo, $name)
263264
);
264265
}
265266

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,18 @@ public function testGetManifest()
291291

292292
public function testGetTags()
293293
{
294-
$endpoint = 'repositories/gentle/eof/tags';
294+
$endpoint = 'repositories/gentle/eof/refs/tags/tagname';
295295
$expectedResult = json_encode('dummy');
296296

297-
$repository = $this->getApiMock('Bitbucket\API\Repositories\Repository');
298-
$repository->expects($this->once())
299-
->method('requestGet')
297+
$client = $this->getHttpClientMock();
298+
$client->expects($this->once())
299+
->method('get')
300300
->with($endpoint)
301301
->will($this->returnValue($expectedResult));
302302

303-
/** @var $repository \Bitbucket\API\Repositories\Repository */
304-
$actual = $repository->tags('gentle', 'eof');
303+
/** @var \Bitbucket\API\Repositories\Repository $repo */
304+
$repo = $this->getClassMock('Bitbucket\API\Repositories\Repository', $client);
305+
$actual = $repo->tags('gentle', 'eof', 'tagname');
305306

306307
$this->assertEquals($expectedResult, $actual);
307308
}

0 commit comments

Comments
 (0)