Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix git describe --tags on topic branches #136

Merged
merged 1 commit into from Nov 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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