Skip to content

Commit

Permalink
Merge pull request #136 from native-api/find_version_topic_branches
Browse files Browse the repository at this point in the history
Fix git describe --tags on topic branches
  • Loading branch information
skvark committed Nov 1, 2018
2 parents 2b31b7f + 7e5a380 commit 77a3278
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 77a3278

Please sign in to comment.