improve error reporting
collect stderr and report it when some of the git query commands fail Change-Id: I2bcabec71518e32416581f2d0107c45c69795bd3
This commit is contained in:
parent
41bb230463
commit
35c4473375
@ -72,21 +72,29 @@ def sha_for_tag(workdir, repo, version):
|
||||
actual_sha = subprocess.check_output(
|
||||
['git', 'log', str(version), '-n', '1', '--pretty=format:%H'],
|
||||
cwd=os.path.join(workdir, repo),
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
actual_sha = actual_sha.strip()
|
||||
except subprocess.CalledProcessError:
|
||||
except subprocess.CalledProcessError as e:
|
||||
print('ERROR getting SHA for tag %r: %s [%s]' %
|
||||
(version, e, e.output.strip()))
|
||||
actual_sha = ''
|
||||
return actual_sha
|
||||
|
||||
|
||||
def check_ancestry(workdir, repo, old_version, sha):
|
||||
"Check if the SHA is in the ancestry of the previous version."
|
||||
ancestors = subprocess.check_output(
|
||||
['git', 'log', '--oneline', '--ancestry-path',
|
||||
'%s..%s' % (old_version, sha)],
|
||||
cwd=os.path.join(workdir, repo),
|
||||
).strip()
|
||||
return bool(ancestors)
|
||||
try:
|
||||
ancestors = subprocess.check_output(
|
||||
['git', 'log', '--oneline', '--ancestry-path',
|
||||
'%s..%s' % (old_version, sha)],
|
||||
cwd=os.path.join(workdir, repo),
|
||||
stderr=subprocess.STDOUT,
|
||||
).strip()
|
||||
return bool(ancestors)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print('ERROR checking ancestry: %s [%s]' % (e, e.output.strip()))
|
||||
return False
|
||||
|
||||
|
||||
def get_latest_tag(workdir, repo):
|
||||
@ -94,6 +102,9 @@ def get_latest_tag(workdir, repo):
|
||||
return subprocess.check_output(
|
||||
['git', 'describe', '--abbrev=0'],
|
||||
cwd=os.path.join(workdir, repo),
|
||||
stderr=subprocess.STDOUT,
|
||||
).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
except subprocess.CalledProcessError as e:
|
||||
print('WARNING failed to retrieve latest tag: %s [%s]' %
|
||||
(e, e.output.strip()))
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user