Skip to content

Commit

Permalink
build: tweak the version calculation fallback logic
Browse files Browse the repository at this point in the history
Change-Id: I6aab87fbf5135e206de8e2f4151eaced909edc2e
  • Loading branch information
Pesa committed Apr 22, 2024
1 parent 34a0b3f commit 2907a29
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,12 @@ def version(ctx):
cmd = ['git', 'describe', '--abbrev=8', '--always', '--match', f'{GIT_TAG_PREFIX}*']
version_from_git = subprocess.run(cmd, capture_output=True, check=True, text=True).stdout.strip()
if version_from_git:
if version_from_git.startswith(GIT_TAG_PREFIX):
Context.g_module.VERSION = version_from_git.lstrip(GIT_TAG_PREFIX)
if GIT_TAG_PREFIX and version_from_git.startswith(GIT_TAG_PREFIX):
Context.g_module.VERSION = version_from_git[len(GIT_TAG_PREFIX):]
elif not GIT_TAG_PREFIX and ('.' in version_from_git or '-' in version_from_git):
Context.g_module.VERSION = version_from_git
else:
# no tags matched
# no tags matched (or we are in a shallow clone)
Context.g_module.VERSION = f'{VERSION_BASE}+git.{version_from_git}'
except (OSError, subprocess.SubprocessError):
pass
Expand Down

0 comments on commit 2907a29

Please sign in to comment.