mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Suggestion to update BUILD_VERSION policy (#1733)
* version.h: update BUILD_VERSION policy / PoC * Fix misplaced chars * make_translation.py: implement get_version_suffix() function to extend BUILD_VERSION build type legend data * version.h: update version policy info according to implementation of get_version_suffix() function in make_translation.py * Version policy update: add double-check for release tag so if version doesn't match use another letter T * make_translation.py: fix extra tabulation * version.h: tiny tidy update for version format * Documentation/DebugMenu.md: update info on version line & date * Documentation/DebugMenu.md: fix formatting & mistypes --------- Co-authored-by: discip <53649486+discip@users.noreply.github.com>
This commit is contained in:
@@ -1263,6 +1263,48 @@ def get_translation_sanity_checks_text(defs: dict) -> str:
|
||||
return sanity_checks_text
|
||||
|
||||
|
||||
def get_version_suffix(ver) -> str:
|
||||
suffix = str("")
|
||||
try:
|
||||
# Use commands _hoping_ they won't be too new for one environments nor deprecated for another ones:
|
||||
## - get commit id; --short=8 - the shorted hash with 8 digits (increase/decrease if needed!)
|
||||
sha_id = f"{subprocess.check_output(['git', 'rev-parse', '--short=8', 'HEAD']).strip().decode('ascii').upper()}"
|
||||
## - if the exact commit relates to tag, then this command should return one-line tag name:
|
||||
tag = f"{subprocess.check_output(['git', 'tag', '--points-at', '%s' % sha_id]).strip().decode('ascii')}"
|
||||
## - get short "traditional" branch name (as in `git branch` for that one with asterisk):
|
||||
branch = f"{subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD']).strip().decode('ascii')}"
|
||||
if tag and "" != tag:
|
||||
# _Speculate_ on tag that it's Release...
|
||||
if ver == tag:
|
||||
# ... but only if double-check for tag is matched
|
||||
suffix = "R"
|
||||
else:
|
||||
# ... otherwise it's tagged but not a release version!
|
||||
suffix = "T"
|
||||
elif branch and "" != branch:
|
||||
# _Hardcoded_ current main development branch...
|
||||
if "dev" == branch:
|
||||
suffix = "D"
|
||||
# ... or some other branch
|
||||
else:
|
||||
suffix = "B"
|
||||
else:
|
||||
# Something else but from Git
|
||||
suffix = "G"
|
||||
# Attach SHA commit to ID a build since it's from git anyway
|
||||
suffix += "." + sha_id
|
||||
except subprocess.CalledProcessError:
|
||||
# No git tree so _probably_ Homebrew build from source
|
||||
suffix = "H"
|
||||
except OSError:
|
||||
# Something _special_?
|
||||
suffix = "S"
|
||||
if "" == suffix:
|
||||
# Something _very_ special!
|
||||
suffix = "V"
|
||||
return suffix
|
||||
|
||||
|
||||
def read_version() -> str:
|
||||
with open(HERE.parent / "source" / "version.h") as version_file:
|
||||
for line in version_file:
|
||||
@@ -1270,11 +1312,7 @@ def read_version() -> str:
|
||||
matches = re.findall(r"\"(.+?)\"", line)
|
||||
if matches:
|
||||
version = matches[0]
|
||||
try:
|
||||
version += f".{subprocess.check_output(['git', 'rev-parse', '--short=7', 'HEAD']).strip().decode('ascii').upper()}"
|
||||
# --short=7: the shorted hash with 7 digits. Increase/decrease if needed!
|
||||
except OSError:
|
||||
version += " git"
|
||||
version += get_version_suffix(version)
|
||||
return version
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user