Skip to content

Commit

Permalink
Fix marking build version segments when there's a pre-release segment
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewWilkes authored and thinkl33t committed Jun 19, 2024
1 parent 1e47239 commit c2b76a9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/st3m/host-tools/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import subprocess
import sys
import os
import re


def get_git_based_version():
Expand All @@ -19,9 +20,14 @@ def get_git_based_version():
version = subprocess.check_output(
["git", "describe", "--tags", "--always"]
).decode().strip()
if '-' in version:
version = version.replace("-", "+", 1)
version = version.replace("-", ".")
commit_hash = subprocess.check_output(
["git", "describe", "--always"]
).decode().strip()
if version.endswith(commit_hash):
build_info = re.compile(f"\-(\d+)\-(.*?{re.escape(commit_hash)})").findall(version)
if build_info:
ahead, commit_hash = build_info[0]
version = version.replace(f"-{ahead}-{commit_hash}", f"+{ahead}.{commit_hash}", 1)
return version

fmt = None
Expand Down

0 comments on commit c2b76a9

Please sign in to comment.