[FIX] runbot: ignore rebuilds in _find_new_commits

When rebuilding a build/subbuild, the last commit of the branch
won't have the same sha of the branch last commit. find_new_commit
will kill the running builds in the branch and create a new one,
that may be a duplicate of one of the killed commits.

This fix only take normal builds into account when checking for
existing builds.
This commit is contained in:
Xavier-Do 2019-12-04 15:44:00 +01:00
parent f2db93fc63
commit b69d40af59

View File

@ -267,7 +267,7 @@ class runbot_repo(models.Model):
self.env.cr.execute("""
SELECT DISTINCT ON (branch_id) name, branch_id
FROM runbot_build WHERE branch_id in %s ORDER BY branch_id,id DESC;
FROM runbot_build WHERE branch_id in %s AND build_type = 'normal' ORDER BY branch_id,id DESC;
""", (tuple([ref_branches[r[0]] for r in refs]),))
# generate a set of tuples (branch_id, sha)
builds_candidates = {(r[1], r[0]) for r in self.env.cr.fetchall()}
@ -293,6 +293,7 @@ class runbot_repo(models.Model):
'committer_email': committer_email,
'subject': subject,
'date': dateutil.parser.parse(date[:19]),
'build_type': 'normal',
}
if not branch.sticky:
# pending builds are skipped as we have a new ref