From 69fa2472e39f1062e76056c4d777e6726b203fed Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Sat, 17 Jan 2015 12:54:29 +0100 Subject: [PATCH] [FIX] runbot: fixed strange red build bug for repositories having dependencies There was an uncaught exception raised by one of the git command in certain cases when searching for the right branch in the dependencies repositories. Because of this error, the dependencies process never finished, and in some case there was no server to run because the server was located on a dependency repo. With no server to run, the build would fail instantly at the start of the testing phase. --- runbot/runbot.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/runbot/runbot.py b/runbot/runbot.py index 8a988c6f..ecfd593f 100644 --- a/runbot/runbot.py +++ b/runbot/runbot.py @@ -568,9 +568,15 @@ class runbot_build(osv.osv): possible_branches = hinted_branches common_refs = {} for target_branch_name in possible_branches: - commit = repo.git(['merge-base', branch.name, target_branch_name]).strip() - cmd = ['log', '-1', '--format=%cd', '--date=iso', commit] - common_refs[target_branch_name] = repo.git(cmd).strip() + try: + commit = repo.git(['merge-base', branch.name, target_branch_name]).strip() + cmd = ['log', '-1', '--format=%cd', '--date=iso', commit] + common_refs[target_branch_name] = repo.git(cmd).strip() + except subprocess.CalledProcessError: + # If merge-base doesn't find any common ancestor, the command exits with a + # non-zero return code, resulting in subprocess.check_output raising this + # exception. We ignore this branch as there is no common ref between us. + continue if common_refs: name = sorted(common_refs.iteritems(), key=operator.itemgetter(1), reverse=True)[0][0] return name