From c974f510366e00e023773cfe13669528a6f8ee6f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 18 Nov 2024 13:09:23 +0100 Subject: [PATCH] [IMP] runbot_merge: trigger staging if re-enabled for branch If staging gets re-enabled on a branch (or the branch itself gets re-enabled), immediately run a staging cron as there may already be PRs waiting, and no trigger enqueued: cron triggers have no payload, they just get removed when the cron runs which means if a bunch of PRs become ready for branch B with staging disabled, the cron is going to run, it's going to stage nothing on that branch (because staging is disabled) then it's going to delete all the triggers. Fixes #979 --- runbot_merge/models/pull_requests.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 4893444c..c0bf5f4e 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -315,6 +315,13 @@ class Branch(models.Model): 'message': tmpl._format(pr=pr), } for pr in actives.prs]) self.env.ref('runbot_merge.branch_cleanup')._trigger() + + if ( + (vals.get('staging_enabled') is True and not all(self.mapped('staging_enabled'))) + or (vals.get('active') is True and not all(self.mapped('active'))) + ): + self.env.ref('runbot_merge.staging_cron')._trigger() + super().write(vals) return True