Handle errors from git describe

The git describe command reports errors if there are no tags to be used
to get a description. Trap the errors in places where it is reasonable
to encounter that situation.

Change-Id: I436af248b1740c493b14178cbbe59c8b0474aa94
This commit is contained in:
Doug Hellmann
2015-08-31 14:54:44 +00:00
parent 9339758a1f
commit 890aaa12c1
2 changed files with 14 additions and 8 deletions

View File

@@ -161,9 +161,12 @@ def main():
# Show more details about the commit being tagged.
print()
print('git describe %s' % project['hash'])
subprocess.call(
['git', 'describe', project['hash']],
cwd=os.path.join(workdir, project['repo']),
)
try:
subprocess.check_call(
['git', 'describe', project['hash']],
cwd=os.path.join(workdir, project['repo']),
)
except subprocess.CalledProcessError as e:
print('WARNING: Could not run git describe: %s' % e)
return 0

View File

@@ -90,7 +90,10 @@ def check_ancestry(workdir, repo, old_version, sha):
def get_latest_tag(workdir, repo):
return subprocess.check_output(
['git', 'describe', '--abbrev=0'],
cwd=os.path.join(workdir, repo),
).strip()
try:
return subprocess.check_output(
['git', 'describe', '--abbrev=0'],
cwd=os.path.join(workdir, repo),
).strip()
except subprocess.CalledProcessError:
return None