[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
This commit is contained in:
Xavier Morel 2024-11-18 13:09:23 +01:00
parent 5441ba12ae
commit c974f51036

View File

@ -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