Skip to content

Commit ec55aee

Browse files
committed
Add commit builds to Repository API
1 parent a1cbde4 commit ec55aee

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

lib/Gitlab/Api/Repositories.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ public function createTag($project_id, $name, $ref, $message = null)
9090
));
9191
}
9292

93+
/**
94+
* @param int $project_id
95+
* @param string $sha
96+
* @param string $scope
97+
* @param int $page
98+
* @param int $per_page
99+
*
100+
* @return mixed
101+
*/
102+
public function commitBuilds($project_id, $sha, $scope = null, $page = 0, $per_page = self::PER_PAGE)
103+
{
104+
return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha).'/builds'), array(
105+
'page' => $page,
106+
'per_page' => $per_page,
107+
'scope' => $scope
108+
));
109+
}
110+
93111
/**
94112
* @param int $project_id
95113
* @param int $page

test/Gitlab/Tests/Api/RepositoriesTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,46 @@ public function shouldGetCommits()
170170
$this->assertEquals($expectedArray, $api->commits(1));
171171
}
172172

173+
/**
174+
* @test
175+
*/
176+
public function shouldGetCommitBuilds()
177+
{
178+
$expectedArray = array(
179+
array('id' => 'abcd1234', 'status' => 'failed'),
180+
array('id' => 'efgh5678', 'status' => 'success')
181+
);
182+
183+
$api = $this->getApiMock();
184+
$api->expects($this->once())
185+
->method('get')
186+
->with('projects/1/repository/commits/abcd12345/builds', array('page' => 0, 'per_page' => AbstractApi::PER_PAGE, 'scope' => null))
187+
->will($this->returnValue($expectedArray))
188+
;
189+
190+
$this->assertEquals($expectedArray, $api->commitBuilds(1, 'abcd12345'));
191+
}
192+
193+
/**
194+
* @test
195+
*/
196+
public function shouldGetCommitBuildsWithScope()
197+
{
198+
$expectedArray = array(
199+
array('id' => 'abcd1234', 'status' => 'success'),
200+
);
201+
202+
$api = $this->getApiMock();
203+
$api->expects($this->once())
204+
->method('get')
205+
->with('projects/1/repository/commits/abcd12345/builds', array('page' => 0, 'per_page' => AbstractApi::PER_PAGE, 'scope' => 'success'))
206+
->will($this->returnValue($expectedArray))
207+
;
208+
209+
$this->assertEquals($expectedArray, $api->commitBuilds(1, 'abcd12345', 'success'));
210+
}
211+
212+
173213
/**
174214
* @test
175215
*/

0 commit comments

Comments
 (0)