|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the bitbucket-api package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Alexandru G. <[email protected]> |
|
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 Bitbucket\API\Repositories\Commits\Comments; |
|
16
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author Alexandru G. <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class Commits extends Api |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Get a list of commits |
|
25
|
|
|
* |
|
26
|
|
|
* @access public |
|
27
|
|
|
* @param string $account The team or individual account owning the repository. |
|
28
|
|
|
* @param string $repo The repository identifier. |
|
29
|
|
|
* @param array $params Additional parameters |
|
30
|
|
|
* @return ResponseInterface |
|
31
|
2 |
|
*/ |
|
32
|
|
|
public function all($account, $repo, array $params = array()) |
|
33
|
2 |
|
{ |
|
34
|
|
|
$endpoint = sprintf('/repositories/%s/%s/commits', $account, $repo); |
|
35
|
2 |
|
|
|
36
|
1 |
|
if (!empty($params['branch'])) { |
|
37
|
1 |
|
$endpoint .= '/'.$params['branch']; // can also be a tag |
|
38
|
|
|
unset($params['branch']); |
|
39
|
|
|
} |
|
40
|
2 |
|
|
|
41
|
2 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
42
|
2 |
|
$endpoint, |
|
43
|
|
|
$params |
|
44
|
|
|
); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Get an individual commit |
|
49
|
|
|
* |
|
50
|
|
|
* @access public |
|
51
|
|
|
* @param string $account The team or individual account owning the repository. |
|
52
|
|
|
* @param string $repo The repository identifier. |
|
53
|
|
|
* @param string $revision A SHA1 value for the commit. |
|
54
|
|
|
* @return ResponseInterface |
|
55
|
1 |
|
*/ |
|
56
|
|
|
public function get($account, $repo, $revision) |
|
57
|
1 |
|
{ |
|
58
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
59
|
|
|
sprintf('/repositories/%s/%s/commit/%s', $account, $repo, $revision) |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Approve a commit |
|
65
|
|
|
* |
|
66
|
|
|
* @access public |
|
67
|
|
|
* @param string $account The team or individual account owning the repository. |
|
68
|
|
|
* @param string $repo The repository identifier. |
|
69
|
|
|
* @param string $revision A SHA1 value for the commit. |
|
70
|
|
|
* @return ResponseInterface |
|
71
|
1 |
|
*/ |
|
72
|
|
|
public function approve($account, $repo, $revision) |
|
73
|
1 |
|
{ |
|
74
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->post( |
|
75
|
|
|
sprintf('/repositories/%s/%s/commit/%s/approve', $account, $repo, $revision) |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Delete a commit approval |
|
81
|
|
|
* |
|
82
|
|
|
* NOTE: On success returns `HTTP/1.1 204 NO CONTENT` |
|
83
|
|
|
* |
|
84
|
|
|
* @access public |
|
85
|
|
|
* @param string $account The team or individual account owning the repository. |
|
86
|
|
|
* @param string $repo The repository identifier. |
|
87
|
|
|
* @param string $revision A SHA1 value for the commit. |
|
88
|
|
|
* @return ResponseInterface |
|
89
|
1 |
|
*/ |
|
90
|
|
|
public function deleteApproval($account, $repo, $revision) |
|
91
|
1 |
|
{ |
|
92
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->delete( |
|
93
|
|
|
sprintf('/repositories/%s/%s/commit/%s/approve', $account, $repo, $revision) |
|
94
|
|
|
); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Get comments |
|
99
|
|
|
* |
|
100
|
|
|
* @access public |
|
101
|
|
|
* @return Commits\Comments |
|
102
|
|
|
* |
|
103
|
|
|
* @throws \InvalidArgumentException |
|
104
|
|
|
* @codeCoverageIgnore |
|
105
|
|
|
*/ |
|
106
|
|
|
public function comments() |
|
107
|
|
|
{ |
|
108
|
|
|
return $this->api(Comments::class); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
|