Skip to content

Commit 2907a29

Browse files
committed
build: tweak the version calculation fallback logic
Change-Id: I6aab87fbf5135e206de8e2f4151eaced909edc2e
1 parent 34a0b3f commit 2907a29

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

wscript

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,12 @@ def version(ctx):
145145
cmd = ['git', 'describe', '--abbrev=8', '--always', '--match', f'{GIT_TAG_PREFIX}*']
146146
version_from_git = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
147147
if version_from_git:
148-
if version_from_git.startswith(GIT_TAG_PREFIX):
149-
Context.g_module.VERSION = version_from_git.lstrip(GIT_TAG_PREFIX)
148+
if GIT_TAG_PREFIX and version_from_git.startswith(GIT_TAG_PREFIX):
149+
Context.g_module.VERSION = version_from_git[len(GIT_TAG_PREFIX):]
150+
elif not GIT_TAG_PREFIX and ('.' in version_from_git or '-' in version_from_git):
151+
Context.g_module.VERSION = version_from_git
150152
else:
151-
# no tags matched
153+
# no tags matched (or we are in a shallow clone)
152154
Context.g_module.VERSION = f'{VERSION_BASE}+git.{version_from_git}'
153155
except (OSError, subprocess.SubprocessError):
154156
pass

0 commit comments

Comments
 (0)