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