Skip to content

Commit 139f663

Browse files
committed
Add support for listing merge requests associated with a commit
1 parent 93f0181 commit 139f663

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/Api/Repositories.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,19 @@ public function commitRefs($project_id, string $sha, array $parameters = [])
268268
);
269269
}
270270

271+
/**
272+
* @param int|string $project_id
273+
* @param string $sha
274+
*
275+
* @return mixed
276+
*/
277+
public function commitMergeRequests($project_id, string $sha)
278+
{
279+
return $this->get(
280+
$this->getProjectPath($project_id, 'repository/commits/'.self::encodePath($sha).'/merge_requests'),
281+
);
282+
}
283+
271284
/**
272285
* @param int|string $project_id
273286
* @param array $parameters {

tests/Api/RepositoriesTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,26 @@ public function shouldGetCommitRefs(): void
361361
$this->assertEquals($expectedArray, $api->commitRefs(1, 'abcd1234'));
362362
}
363363

364+
/**
365+
* @test
366+
*/
367+
public function shouldGetCommitMergeRequests(): void
368+
{
369+
$expectedArray = [
370+
['id' => 1, 'title' => 'A merge request'],
371+
['id' => 2, 'title' => 'Another merge request'],
372+
];
373+
374+
$api = $this->getApiMock();
375+
$api->expects($this->once())
376+
->method('get')
377+
->with('projects/1/repository/commits/abcd1234/merge_requests')
378+
->will($this->returnValue($expectedArray))
379+
;
380+
381+
$this->assertEquals($expectedArray, $api->commitMergeRequests(1, 'abcd1234'));
382+
}
383+
364384
/**
365385
* @test
366386
*

0 commit comments

Comments
 (0)