Fix generate_version_string errors with old versions of git
Change-Id: I870bc65849906a52a94f8e562e780c8bf7924118
This commit is contained in:
parent
9ddf9276ce
commit
6f3e5c77b7
|
@ -30,10 +30,22 @@ if 'check_output' not in dir(subprocess):
|
||||||
subprocess.check_output = check_output_implementation
|
subprocess.check_output = check_output_implementation
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
version_tag = subprocess.check_output(['git', 'tag', '--points-at', 'HEAD'
|
try:
|
||||||
]).rstrip()
|
version_tag = subprocess.check_output(
|
||||||
version_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'
|
['git', 'tag', '--points-at', 'HEAD'],
|
||||||
]).rstrip()
|
stderr=subprocess.STDOUT).rstrip()
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
# git tag --points-at is not supported in old versions of git. Just ignore
|
||||||
|
# version_tag in this case.
|
||||||
|
version_tag = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
version_hash = subprocess.check_output(
|
||||||
|
['git', 'rev-parse', '--short', 'HEAD'],
|
||||||
|
stderr=subprocess.STDOUT).rstrip()
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
version_hash = 'unknown-version'
|
||||||
|
|
||||||
if version_tag:
|
if version_tag:
|
||||||
print '{0}-{1}'.format(version_tag, version_hash)
|
print '{0}-{1}'.format(version_tag, version_hash)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue