mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
utils.py: Fix for is_commit_ancestor()
The runcmd() would print an "ERROR" on failure which causes confusion since the failure is expected on old branches, so subprocess.getstatusoutput to fix the problem. Minor rewording. Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Tim Orling <tim.orling@konsulko.com>
This commit is contained in:
parent
2d7906ff3b
commit
61c857a7df
|
@ -243,16 +243,18 @@ def is_commit_ancestor(repodir, commit, logger):
|
||||||
# check if commit is a sha1 hash
|
# check if commit is a sha1 hash
|
||||||
if re.match('[0-9a-f]{40}', commit):
|
if re.match('[0-9a-f]{40}', commit):
|
||||||
# check if the commit is an ancestor
|
# check if the commit is an ancestor
|
||||||
contained = runcmd(['git', 'merge-base', '--is-ancestor', '%s' % commit, 'HEAD'], repodir, logger=logger)
|
cmd = "GIT_DIR=%s/.git git merge-base --is-ancestor %s HEAD" % (repodir, commit)
|
||||||
return True
|
logger.debug('Running "%s"' % cmd)
|
||||||
else:
|
ret, output = subprocess.getstatusoutput(cmd)
|
||||||
raise Exception('is_commit_ancestor: "commit" must be a SHA1 hash')
|
if ret == 0:
|
||||||
except subprocess.CalledProcessError as e:
|
return True
|
||||||
if e.returncode == 1:
|
elif ret == 1:
|
||||||
# commit is not an ancestor
|
logger.debug('output: %s' % output)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
raise e
|
raise Exception('Failed to run command: %s: ret: %s, output: %s' % (cmd, ret, output))
|
||||||
|
else:
|
||||||
|
raise Exception('is_commit_ancestor: "commit" must be a SHA1 hash')
|
||||||
except Exception as esc:
|
except Exception as esc:
|
||||||
logger.warn(esc)
|
logger.warn(esc)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user