From 5748c086e5722eb1958c56ca10d44d2988ecc7ba Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 16 Oct 2024 12:17:30 +0200 Subject: [PATCH] [FIX] runbot_merge: status of closed PRs in extant batches If a PR is closed but part of an ongoing batch, the change in status of the batch might be reflected on the PR still: - if a PR is closed and the batch gets staged, the PR shows up as being staged - if the PR is merged then the batch gets merged, the PR shows up as merged Fixes #914 Also remove the unused `_tagstate` helper property. --- runbot_merge/models/pull_requests.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 2f16266a..6d1ca7f5 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -431,10 +431,16 @@ class PullRequests(models.Model): staging_id = fields.Many2one('runbot_merge.stagings', compute='_compute_staging', inverse=readonly, readonly=True, store=True) staging_ids = fields.Many2many('runbot_merge.stagings', string="Stagings", compute='_compute_stagings', inverse=readonly, readonly=True, context={"active_test": False}) - @api.depends('batch_id.batch_staging_ids.runbot_merge_stagings_id.active') + @api.depends( + 'closed', + 'batch_id.batch_staging_ids.runbot_merge_stagings_id.active', + ) def _compute_staging(self): for p in self: - p.staging_id = p.batch_id.staging_ids.filtered('active') + if p.closed: + p.staging_id = False + else: + p.staging_id = p.batch_id.staging_ids.filtered('active') @api.depends('batch_id.batch_staging_ids.runbot_merge_stagings_id') def _compute_stagings(self): @@ -1250,10 +1256,10 @@ For your own safety I've ignored *everything in your entire comment*. ) def _compute_state(self): for pr in self: - if pr.batch_id.merge_date: - pr.state = 'merged' - elif pr.closed: + if pr.closed: pr.state = "closed" + elif pr.batch_id.merge_date: + pr.state = 'merged' elif pr.error: pr.state = "error" elif pr.batch_id.skipchecks: # skipchecks behaves as both approval and status override @@ -1338,12 +1344,6 @@ For your own safety I've ignored *everything in your entire comment*. "ON runbot_merge_pull_requests " "USING hash (head)") - @property - def _tagstate(self): - if self.state == 'ready' and self.staging_id.heads: - return 'staged' - return self.state - def _get_batch(self, *, target, label): batch = self.env['runbot_merge.batch'] if not re.search(r':patch-\d+$', label):