Skip to content

Commit 70b1a53

Browse files
committed
implemented Commits::approve (API 2.0)
1 parent ab09188 commit 70b1a53

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

docs/repositories/commits.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ $commits->all($account_name, $repo_slug, array(
2626
$commits->get($account_name, $repo_slug, $commitSHA1);
2727
```
2828

29+
### Approve a commit: (API 2.0)
30+
```php
31+
$commits->approve($account_name, $repo_slug, $commitSHA1);
32+
```
33+
2934
----
3035

3136
#### Related:

lib/Bitbucket/API/Repositories/Commits.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,20 @@ public function get($account, $repo, $revision)
5858
sprintf('repositories/%s/%s/commit/%s', $account, $repo, $revision)
5959
);
6060
}
61+
62+
/**
63+
* Approve a commit
64+
*
65+
* @access public
66+
* @param string $account The team or individual account owning the repository.
67+
* @param string $repo The repository identifier.
68+
* @param string $revision A SHA1 value for the commit.
69+
* @return MessageInterface
70+
*/
71+
public function approve($account, $repo, $revision)
72+
{
73+
return $this->getClient()->setApiVersion('2.0')->post(
74+
sprintf('repositories/%s/%s/commit/%s/approve', $account, $repo, $revision)
75+
);
76+
}
6177
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,19 @@ public function testGetSingleCommitInfo()
6060

6161
$this->assertEquals($expectedResult, $actual);
6262
}
63+
64+
public function testApproveACommit()
65+
{
66+
$endpoint = 'repositories/gentle/eof/commit/SHA1/approve';
67+
68+
$client = $this->getHttpClientMock();
69+
$client->expects($this->once())
70+
->method('post')
71+
->with($endpoint);
72+
73+
/** @var \Bitbucket\API\Repositories\Commits $commit */
74+
$commit = $this->getClassMock('Bitbucket\API\Repositories\Commits', $client);
75+
76+
$commit->approve('gentle', 'eof', 'SHA1');
77+
}
6378
}

0 commit comments

Comments
 (0)