From dbc001f841f121257d4dfd90525948efff6c4c94 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 16 Nov 2021 14:01:23 +0100 Subject: [PATCH] [FIX] runbot_merge: odd behaviour in try_closing Could not reproduce it in a shell, but in the original version `self.env.cr.rowcount` would always be 0 after the `modified`. Turns out the check is really completely dumb, because if we got any match in `select for update` we're going to find the same on in the update, and thus the conditional is unnecessary. I've no idea why I did that. Anyway remove the conditional and just always try to unstage the PR. --- runbot_merge/models/pull_requests.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/runbot_merge/models/pull_requests.py b/runbot_merge/models/pull_requests.py index 38d6a6c2..c83bcff6 100644 --- a/runbot_merge/models/pull_requests.py +++ b/runbot_merge/models/pull_requests.py @@ -1358,23 +1358,21 @@ class PullRequests(models.Model): WHERE id = %s AND state != 'merged' FOR UPDATE SKIP LOCKED; ''', [self.id]) - res = self.env.cr.fetchone() - if not res: + if not self.env.cr.fetchone(): return False self.env.cr.execute(''' UPDATE runbot_merge_pull_requests SET state = 'closed' - WHERE id = %s AND state != 'merged' + WHERE id = %s ''', [self.id]) self.env.cr.commit() self.modified(['state']) - if self.env.cr.rowcount: - self.unstage( - "PR %s closed by %s", - self.display_name, - by - ) + self.unstage( + "PR %s closed by %s", + self.display_name, + by + ) return True # state changes on reviews