File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
components/st3m/host-tools Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1111import subprocess
1212import sys
1313import os
14+ import re
1415
1516
1617def get_git_based_version ():
@@ -19,9 +20,14 @@ def get_git_based_version():
1920 version = subprocess .check_output (
2021 ["git" , "describe" , "--tags" , "--always" ]
2122 ).decode ().strip ()
22- if '-' in version :
23- version = version .replace ("-" , "+" , 1 )
24- version = version .replace ("-" , "." )
23+ commit_hash = subprocess .check_output (
24+ ["git" , "describe" , "--always" ]
25+ ).decode ().strip ()
26+ if version .endswith (commit_hash ):
27+ build_info = re .compile (f"\-(\d+)\-(.*?{ re .escape (commit_hash )} )" ).findall (version )
28+ if build_info :
29+ ahead , commit_hash = build_info [0 ]
30+ version = version .replace (f"-{ ahead } -{ commit_hash } " , f"+{ ahead } .{ commit_hash } " , 1 )
2531 return version
2632
2733fmt = None
You can’t perform that action at this time.
0 commit comments