fix(webhooks): clean up closed GitLab MRs after target branch changes (#12012)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
johandenhollander
2026-10-15 22:55:06 +02:00
committed by GitHub
co-authored by Claude Opus 5.5
parent e02f932a34
commit 1464b751b1
2 changed files with 163 additions and 2 deletions
+8 -2
View File
@@ -231,7 +231,10 @@ class Gitlab extends Controller
'skip_deploy' => $skip_deploy_pr,
] = $this->readMergeRequestPayload($payload);
$applications = $applications->where('git_branch', $base_branch)->get();
if (! in_array($action, ['closed', 'close', 'merge'])) {
$applications->where('git_branch', $base_branch);
}
$applications = $applications->get();
foreach ($applications as $application) {
if (! $application->destination->server->isFunctional()) {
@@ -440,7 +443,10 @@ class Gitlab extends Controller
}
}
if ($x_gitlab_event === 'merge_request') {
$applications = $this->manualWebhookApplications($applications->where('git_branch', $base_branch), $full_name);
if (! in_array($action, ['closed', 'close', 'merge'])) {
$applications->where('git_branch', $base_branch);
}
$applications = $this->manualWebhookApplications($applications, $full_name);
if ($applications->isEmpty()) {
return $this->unauthenticatedManualWebhookResponse($failure_key, $failure_attempt);
}