Skip to content

Commit

Permalink
git describe --tags produces "fatal: No names found, cannot describe …
Browse files Browse the repository at this point in the history
…anything." on topic branches
  • Loading branch information
native-api committed Oct 29, 2018
1 parent 2b31b7f commit 7e5a380
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion find_version.py
Expand Up @@ -25,7 +25,15 @@
# used in local dev releases
git_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).splitlines()[0].decode()
# this outputs the annotated tag if we are exactly on a tag, otherwise <tag>-<n>-g<shortened sha-1>
tag = subprocess.check_output(['git', 'describe', '--tags']).splitlines()[0].decode().split('-')
try:
tag = subprocess.check_output(['git', 'describe', '--tags'], stderr = subprocess.STDOUT).splitlines()[0].decode().split('-')
except subprocess.CalledProcessError as e:
# no tags reachable (e.g. on a topic branch in a fork), see
# https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything
if e.output.rstrip() == b"fatal: No names found, cannot describe anything.":
tag=[]
else:
print(e.output); raise

if len(tag) == 1:
# tag identifies the build and should be a sequential revision number
Expand Down

0 comments on commit 7e5a380

Please sign in to comment.