[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.
This commit is contained in:
Xavier Morel 2021-11-16 14:01:23 +01:00
parent b0995adda0
commit dbc001f841

View File

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