diff --git a/components/st3m/host-tools/version.py b/components/st3m/host-tools/version.py index 3ce39f77a3fb44bf7708e7e1fd4ba92c71ed03a6..ece01cf3a21d03ec5cfc587d2a0921b363c71335 100644 --- a/components/st3m/host-tools/version.py +++ b/components/st3m/host-tools/version.py @@ -13,105 +13,10 @@ import sys import os -class Tag: - def __init__(self, name, rc): - self.name = name - self.rc = rc - - def __repr__(self): - return self.name - - -def tags_for_commit(release, commit): - res = [] - tags = ( - subprocess.check_output( - [ - "git", - "tag", - "--contains", - commit, - ] - ) - .decode() - .strip() - ) - for tag in tags.split("\n"): - tag = tag.strip() - if not tag: - continue - if not tag.startswith("v" + release): - continue - if tag == "v" + release: - res.append(Tag(tag, False)) - continue - if tag.startswith("v" + release + "+rc"): - res.append(Tag(tag, True)) - continue - return res - - def get_git_based_version(): - commit = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip() - branches = ( - subprocess.check_output( - [ - "git", - "branch", - "--format", - "%(refname)", - "--contains", - commit, - ] - ) - .decode() - .strip() - ) - - release = None - for branch in branches.split("\n"): - branch = branch.strip() - if not branch: - continue - parts = branch.split("/") - if len(parts) != 4: - continue - - if parts[:3] != ["refs", "heads", "release"]: - continue - v = parts[3] - release = v - break - - main_count = ( - subprocess.check_output( - [ - "git", - "rev-list", - "--count", - commit, - ] - ) - .decode() - .strip() - ) - - version = None - if release is None: - version = f"v0-dev{main_count}" - return version - - tags = tags_for_commit(release, commit) - if not tags: - return f"v{release}-dev{main_count}" - - releases = sorted([t for t in tags if not t.rc]) - candidates = sorted([t for t in tags if t.rc]) - - if releases: - return str(releases[0]) - else: - return str(candidates[0]) + return subprocess.check_output( + ["git", "describe", "--tags"] + ).decode().strip() fmt = None diff --git a/components/st3m/st3m_gfx.c b/components/st3m/st3m_gfx.c index 2cc1ff2b9061363b9e7e2e25ad56fae09e908727..84cd84666303d14a6cc6f007470ba6788fef2684 100644 --- a/components/st3m/st3m_gfx.c +++ b/components/st3m/st3m_gfx.c @@ -902,7 +902,7 @@ void st3m_gfx_show_textview(st3m_gfx_textview_t *tv) { // Draw version. ctx_font_size(ctx, 15.0); ctx_gray(ctx, 0.6); - ctx_move_to(ctx, 0, 100); + ctx_move_to(ctx, 0, 90); ctx_text(ctx, st3m_version); ctx_restore(ctx); diff --git a/python_payload/apps/updat3r/__init__.py b/python_payload/apps/updat3r/__init__.py index 7405a6dfac204cb8854eb872e5c59cc22cf606ff..fe5a95464e5a5632b1a0489efa6618a5e4dbbf74 100644 --- a/python_payload/apps/updat3r/__init__.py +++ b/python_payload/apps/updat3r/__init__.py @@ -35,7 +35,10 @@ class UpdaterApp(Application): ctx.font_size = 15 ctx.move_to(0, -90) ctx.text("you are running") - ctx.font_size = 25 + if len(self._firmware_version) > 10: + ctx.font_size = 18 + else: + ctx.font_size = 25 ctx.move_to(0, -70) ctx.text(self._firmware_version) @@ -62,8 +65,14 @@ class UpdaterApp(Application): def version_to_number(self, version: str): if "dev" in version: return 0 + major, minor, patch = version.split(".") - version_number = (int(major) * 1000000) + (int(major) * 1000) + int(patch) + + try: + version_number = (int(major) * 1000000) + (int(major) * 1000) + int(patch) + except ValueError: + return 0 + return version_number def on_enter(self, vm: Optional[ViewManager]):