Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 77a3278

Browse filesBrowse files
authored
Merge pull request opencv#136 from native-api/find_version_topic_branches
Fix git describe --tags on topic branches
2 parents 2b31b7f + 7e5a380 commit 77a3278
Copy full SHA for 77a3278

File tree

1 file changed

+9
-1
lines changed
Filter options

1 file changed

+9
-1
lines changed

‎find_version.py

Copy file name to clipboardExpand all lines: find_version.py
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@
2525
# used in local dev releases
2626
git_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).splitlines()[0].decode()
2727
# this outputs the annotated tag if we are exactly on a tag, otherwise <tag>-<n>-g<shortened sha-1>
28-
tag = subprocess.check_output(['git', 'describe', '--tags']).splitlines()[0].decode().split('-')
28+
try:
29+
tag = subprocess.check_output(['git', 'describe', '--tags'], stderr = subprocess.STDOUT).splitlines()[0].decode().split('-')
30+
except subprocess.CalledProcessError as e:
31+
# no tags reachable (e.g. on a topic branch in a fork), see
32+
# https://stackoverflow.com/questions/4916492/git-describe-fails-with-fatal-no-names-found-cannot-describe-anything
33+
if e.output.rstrip() == b"fatal: No names found, cannot describe anything.":
34+
tag=[]
35+
else:
36+
print(e.output); raise
2937

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.