|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of the bitbucket-api package. |
| 5 | + * |
| 6 | + * (c) Alexandru G. <alex@gentle.ro> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Bitbucket\API\Repositories; |
| 13 | + |
| 14 | +use Bitbucket\API\Api; |
| 15 | +use Buzz\Message\MessageInterface; |
| 16 | + |
| 17 | +/** |
| 18 | + * @author Alexandru G. <alex@gentle.ro> |
| 19 | + */ |
| 20 | +class Commits extends Api |
| 21 | +{ |
| 22 | + /** |
| 23 | + * Get a list of pull requests |
| 24 | + * |
| 25 | + * @access public |
| 26 | + * @param string $account The team or individual account owning the repository. |
| 27 | + * @param string $repo The repository identifier. |
| 28 | + * @param array $params Additional parameters |
| 29 | + * @return MessageInterface |
| 30 | + */ |
| 31 | + public function all($account, $repo, $params = array()) |
| 32 | + { |
| 33 | + $endpoint = sprintf('repositories/%s/%s/commits', $account, $repo); |
| 34 | + |
| 35 | + if (!empty($params['branch'])) { |
| 36 | + $endpoint .= '/'.$params['branch']; // can also be a tag |
| 37 | + unset($params['branch']); |
| 38 | + } |
| 39 | + |
| 40 | + return $this->getClient()->setApiVersion('2.0')->post( |
| 41 | + $endpoint, |
| 42 | + $params |
| 43 | + ); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Get an individual commit |
| 48 | + * |
| 49 | + * @access public |
| 50 | + * @param string $account The team or individual account owning the repository. |
| 51 | + * @param string $repo The repository identifier. |
| 52 | + * @param string $revision A SHA1 value for the commit. |
| 53 | + * @return MessageInterface |
| 54 | + */ |
| 55 | + public function get($account, $repo, $revision) |
| 56 | + { |
| 57 | + return $this->getClient()->setApiVersion('2.0')->get( |
| 58 | + sprintf('repositories/%s/%s/commit/%s', $account, $repo, $revision) |
| 59 | + ); |
| 60 | + } |
| 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 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * Delete a commit approval |
| 80 | + * |
| 81 | + * NOTE: On success returns `HTTP/1.1 204 NO CONTENT` |
| 82 | + * |
| 83 | + * @access public |
| 84 | + * @param string $account The team or individual account owning the repository. |
| 85 | + * @param string $repo The repository identifier. |
| 86 | + * @param string $revision A SHA1 value for the commit. |
| 87 | + * @return MessageInterface |
| 88 | + */ |
| 89 | + public function deleteApproval($account, $repo, $revision) |
| 90 | + { |
| 91 | + return $this->getClient()->setApiVersion('2.0')->delete( |
| 92 | + sprintf('repositories/%s/%s/commit/%s/approve', $account, $repo, $revision) |
| 93 | + ); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Get comments |
| 98 | + * |
| 99 | + * @access public |
| 100 | + * @return Commits\Comments |
| 101 | + * @codeCoverageIgnore |
| 102 | + */ |
| 103 | + public function comments() |
| 104 | + { |
| 105 | + return $this->childFactory('Repositories\\Commits\\Comments'); |
| 106 | + } |
| 107 | +} |
0 commit comments