Skip to content

Commit bb65b27

Browse files
committed
Merged in khoweengage/bitbucket-api/refstagname (pull request #32)
Adding API 2.0 support for GET refs/tags/name
2 parents 02c4f1e + f85eb08 commit bb65b27

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

lib/Bitbucket/API/Repositories/Refs/Tags.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ public function all($account, $repo)
3333
);
3434
}
3535

36+
/**
37+
* Get an individual tag
38+
*
39+
* @access public
40+
* @param string $account The team or individual account owning the repository.
41+
* @param string $repo The repository identifier.
42+
* @param string $name The tag identifier.
43+
* @return MessageInterface
44+
*/
45+
public function get($account, $repo, $name)
46+
{
47+
return $this->getClient()->setApiVersion('2.0')->get(
48+
sprintf('repositories/%s/%s/refs/tags/%s', $account, $repo, $name)
49+
);
50+
}
51+
3652
/**
3753
* Create a new tag
3854
*

test/Bitbucket/Tests/API/Repositories/Refs/TagsTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ public function testAll()
2525
$this->assertEquals($expectedResult, $actual);
2626
}
2727

28+
public function testGet()
29+
{
30+
$endpoint = 'repositories/gentle/eof/refs/tags/atag';
31+
$expectedResult = json_encode('dummy');
32+
33+
$client = $this->getHttpClientMock();
34+
$client->expects($this->once())
35+
->method('get')
36+
->with($endpoint)
37+
->will($this->returnValue($expectedResult));
38+
39+
$repository = $this->getClassMock('Bitbucket\API\Repositories\Refs\Tags', $client);
40+
41+
/** @var $repository \Bitbucket\API\Repositories\Refs\Tags */
42+
$actual = $repository->get('gentle', 'eof', 'atag');
43+
44+
$this->assertEquals($expectedResult, $actual);
45+
}
46+
2847
public function testCreate()
2948
{
3049
$endpoint = 'repositories/gentle/eof/refs/tags';
@@ -39,7 +58,7 @@ public function testCreate()
3958
$repository = $this->getClassMock('Bitbucket\API\Repositories\Refs\Tags', $client);
4059

4160
/** @var $repository \Bitbucket\API\Repositories\Refs\Tags */
42-
$actual = $repository->create('gentle', 'eof', 'tagName', '2310abb944423ecf1a90be9888dafd096744b531');
61+
$actual = $repository->create('gentle', 'eof', 'atag', '2310abb944423ecf1a90be9888dafd096744b531');
4362

4463
$this->assertEquals($expectedResult, $actual);
4564
}

0 commit comments

Comments
 (0)