[FIX] runbot: take parent into account when searching last branch build

If a branch triggers an hidden build on a another one (sticky ususally),
the last build of the branch will be considered to be this one and
trigger a new build. The same problem can occur when cloning a subbuild
to slighlty change a parameter instead of making an exact rebuild
since the build type may still be normal in this case.

This commit will simply ignore subbuild in this case.
This commit is contained in:
Xavier-Do 2020-02-20 15:34:08 +01:00
parent d9ff43fa6b
commit ef7029668a

View File

@ -328,7 +328,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 AND build_type = 'normal' ORDER BY branch_id,id DESC;
FROM runbot_build WHERE branch_id in %s AND build_type = 'normal' AND parent_id is null 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()}