From 6b098b6639aed23a5380ad59502a93393bd793ab Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Wed, 6 May 2026 15:49:52 +0100 Subject: [PATCH] Add merge request removal API --- CHANGELOG.md | 1 + src/Api/MergeRequests.php | 5 +++++ tests/Api/MergeRequestsTest.php | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa2d0e2..3b5b2e80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add support for project CI/CD job token scope endpoints * Add support for merge request resource label event endpoints * Add support for merge request and merge request note award emoji endpoints +* Add support for `MergeRequests::remove` * Add support for `Environments::stopStale` * Add support for `last_activity_after` and `last_activity_before` in `Groups::projects` * Fix `Projects::pipelines` date filters to include time information diff --git a/src/Api/MergeRequests.php b/src/Api/MergeRequests.php index 850285a6..4f3fa5ea 100644 --- a/src/Api/MergeRequests.php +++ b/src/Api/MergeRequests.php @@ -308,6 +308,11 @@ public function update(int|string $project_id, int $mr_iid, array $parameters): return $this->put($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid)), $parameters); } + public function remove(int|string $project_id, int $mr_iid): mixed + { + return $this->delete($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid))); + } + public function merge(int|string $project_id, int $mr_iid, array $parameters = []): mixed { return $this->put($this->getProjectPath($project_id, 'merge_requests/'.self::encodePath($mr_iid).'/merge'), $parameters); diff --git a/tests/Api/MergeRequestsTest.php b/tests/Api/MergeRequestsTest.php index 9d7090c6..0d664c8b 100644 --- a/tests/Api/MergeRequestsTest.php +++ b/tests/Api/MergeRequestsTest.php @@ -318,6 +318,20 @@ public function shouldUpdateMergeRequest(): void ])); } + #[Test] + public function shouldRemoveMergeRequest(): void + { + $expectedBool = true; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('delete') + ->with('projects/1/merge_requests/2') + ->willReturn($expectedBool); + + $this->assertEquals($expectedBool, $api->remove(1, 2)); + } + #[Test] public function shouldMergeMergeRequest(): void {