diff --git a/src/Api/Repositories.php b/src/Api/Repositories.php index eded16b9..9a6c2a81 100644 --- a/src/Api/Repositories.php +++ b/src/Api/Repositories.php @@ -185,6 +185,13 @@ public function commitRefs(int|string $project_id, string $sha, array $parameter ); } + public function commitMergeRequests(int|string $project_id, string $sha): mixed + { + return $this->get( + $this->getProjectPath($project_id, 'repository/commits/'.self::encodePath($sha).'/merge_requests'), + ); + } + /** * @param array $parameters { * diff --git a/tests/Api/RepositoriesTest.php b/tests/Api/RepositoriesTest.php index 3b5d7334..e29e814b 100644 --- a/tests/Api/RepositoriesTest.php +++ b/tests/Api/RepositoriesTest.php @@ -328,6 +328,24 @@ public function shouldGetCommitRefs(): void $this->assertEquals($expectedArray, $api->commitRefs(1, 'abcd1234')); } + #[Test] + public function shouldGetCommitMergeRequests(): void + { + $expectedArray = [ + ['id' => 1, 'title' => 'A merge request'], + ['id' => 2, 'title' => 'Another merge request'], + ]; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/repository/commits/abcd1234/merge_requests') + ->will($this->returnValue($expectedArray)) + ; + + $this->assertEquals($expectedArray, $api->commitMergeRequests(1, 'abcd1234')); + } + #[Test] #[DataProvider('dataGetCommitRefsWithParams')] public function shouldGetCommitRefsWithParams(string $type, array $expectedArray): void