Skip to content

Commit

Permalink
[FIX] runbot_merge: set staging_end on all terminations
Browse files Browse the repository at this point in the history
Rather than only setting `staging_end` on status change, set it when
the staging gets deactivated. This way cancelling a staging (whether
explicitely or via a PR update) will also end it, so will a staging
timeout, etc..., rather than keep the counter running.

Fixes #931
  • Loading branch information
xmo-odoo committed Sep 6, 2024
1 parent 64f9dcb commit 146564a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion runbot_merge/models/pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2049,6 +2049,7 @@ def write(self, vals):
._trigger(fields.Datetime.to_datetime(timeout))

if vals.get('active') is False:
vals['staging_end'] = fields.Datetime.now()
self.env.ref("runbot_merge.staging_cron")._trigger()

return super().write(vals)
Expand Down Expand Up @@ -2141,7 +2142,6 @@ def _compute_state(self):
s.state = st
if s.state != 'pending':
self.env.ref("runbot_merge.merge_cron")._trigger()
s.staging_end = fields.Datetime.now()
if update_timeout_limit:
s.timeout_limit = datetime.datetime.now() + datetime.timedelta(minutes=s.target.project_id.ci_timeout)
self.env.ref("runbot_merge.merge_cron")._trigger(s.timeout_limit)
Expand Down

0 comments on commit 146564a

Please sign in to comment.