From 1c76a675c28bb2b120927682afca29e5334d472f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 26 Jun 2024 14:30:31 +0200 Subject: [PATCH] [IMP] runbot_merge: cancel splits on cancel=staging If a PR is cancel=staging, even if it's not the urgentest (priority=alone) odds are good it's being staged to fix the split. And even if it's not, it probably can't hurt. So cancel splits in order to stage it. This may be slightly harmful if the split is legit and has nothing to do with the PR being prioritised, but that seems like the less likely scenario. And having to update staging priorities on the fly seems like a bad idea. Though obviously it might do nothing if the PRs are in "default" priority.# Also simplify the unstage trigger from the PRs becoming ready: - the user is useless as it's always the system user - the batch id is not really helpful --- runbot_merge/models/batch.py | 6 +++--- runbot_merge/models/pull_requests.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/runbot_merge/models/batch.py b/runbot_merge/models/batch.py index fbca57fc..d35f743d 100644 --- a/runbot_merge/models/batch.py +++ b/runbot_merge/models/batch.py @@ -227,10 +227,10 @@ class Batch(models.Model): batch.blocked = f"Multiple target branches: {', '.join(targets.mapped('name'))!r}" else: if batch.blocked and batch.cancel_staging: + if splits := batch.target.split_ids: + splits.unlink() batch.target.active_staging_id.cancel( - 'unstaged by %s on %s (%s)', - self.env.user.login, - batch, + 'unstaged by %s becoming ready', ', '.join(batch.prs.mapped('display_name')), ) batch.blocked = False diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 76bc6a9f..927536af 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -842,6 +842,8 @@ For your own safety I've ignored *everything in your entire comment*. case commands.CancelStaging() if is_admin: self.batch_id.cancel_staging = True if not self.batch_id.blocked: + if splits := self.target.split_ids: + splits.unlink() self.target.active_staging_id.cancel( "Unstaged by %s on %s", author.github_login, self.display_name,