mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[IMP] forwardport: fix creation of FP PR in some testing cases
When running tests on some machines, it's apparently possible for the PR-creation webhook to come back before the PR creation request has, leading to the creation of the PR from the API call duplicating that of the webhook and blowing up. To fix, immediately commit the transaction then check if we already have the PR we just created in the system, and only create it explicitly if not.
This commit is contained in:
parent
c5d68c20f4
commit
e9e08fec3c
@ -486,8 +486,18 @@ class PullRequests(models.Model):
|
||||
}
|
||||
)
|
||||
assert 200 <= r.status_code < 300, r.json()
|
||||
new_pr = self._from_gh(r.json())
|
||||
_logger.info("Created forward-port PR %s", new_pr)
|
||||
r = r.json()
|
||||
self.env.cr.commit()
|
||||
|
||||
new_pr = self.search([
|
||||
('number', '=', r['number']),
|
||||
('repository.name', '=', r['base']['repo']['full_name']),
|
||||
], limit=1)
|
||||
if new_pr:
|
||||
_logger.info("Received forward-port PR %s", new_pr)
|
||||
else:
|
||||
new_pr = self._from_gh(r)
|
||||
_logger.info("Created forward-port PR %s", new_pr)
|
||||
new_batch |= new_pr
|
||||
|
||||
new_pr.write({
|
||||
|
Loading…
Reference in New Issue
Block a user