Skip to content

Commit 9f31824

Browse files
drummm1guelpf
authored andcommitted
Add repository merge base API support
1 parent a60b54d commit 9f31824

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

lib/Gitlab/Api/Repositories.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,14 @@ public function archive($project_id, $params = array(), $format = 'tar.gz')
460460
{
461461
return $this->get($this->getProjectPath($project_id, 'repository/archive.'.$format), $params);
462462
}
463+
464+
/**
465+
* @param int $project_id
466+
* @param array $refs
467+
* @return mixed
468+
*/
469+
public function mergeBase($project_id, $refs)
470+
{
471+
return $this->get($this->getProjectPath($project_id, 'repository/merge_base'), array('refs' => $refs));
472+
}
463473
}

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,38 @@ public function shouldArchiveProject()
193193
$this->assertEquals($expectedArray, $api->archive(1));
194194
}
195195

196+
/**
197+
* @test
198+
*/
199+
public function shouldGetMergeBase()
200+
{
201+
$expectedArray = array(
202+
'id' => 'abcd1234abcd1234abcd1234abcd1234abcd1234',
203+
'short_id' => 'abcd1234',
204+
'title' => 'A commit',
205+
'created_at' => '2018-01-01T00:00:00.000Z',
206+
'parent_ids' => array(
207+
'efgh5678efgh5678efgh5678efgh5678efgh5678',
208+
),
209+
'message' => 'A commit',
210+
'author_name' => 'Jane Doe',
211+
'author_email' => '[email protected]',
212+
'authored_date' => '2018-01-01T00:00:00.000Z',
213+
'committer_name' => 'Jane Doe',
214+
'committer_email' => '[email protected]',
215+
'committed_date' => '2018-01-01T00:00:00.000Z',
216+
);
217+
218+
$api = $this->getApiMock();
219+
$api->expects($this->once())
220+
->method('get')
221+
->with('projects/1/repository/merge_base', array('refs' => array('efgh5678efgh5678efgh5678efgh5678efgh5678', '1234567812345678123456781234567812345678')))
222+
->will($this->returnValue($expectedArray))
223+
;
224+
225+
$this->assertEquals($expectedArray, $api->archive(1, array('efgh5678efgh5678efgh5678efgh5678efgh5678', '1234567812345678123456781234567812345678')));
226+
}
227+
196228
/**
197229
* @test
198230
*/

0 commit comments

Comments
 (0)