From bd048d9e25f503f8b0f246f6f455768b1e1ca7f2 Mon Sep 17 00:00:00 2001 From: MarekZegare4 Date: Thu, 25 Jun 2026 19:01:24 +0200 Subject: [PATCH] fix(ui): keep pre-release suffix in splash-screen firmware version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All three UI variants stripped the displayed version at the FIRST dash, assuming it was always the commit-hash separator build.sh appends. A tag containing its own dash (e.g. v1.21-rc1) has that dash earlier, so the splash screen silently dropped "-rc1" and showed just "v1.21" — no way to tell an RC from the final release on-device. Strip at the LAST dash instead, since build.sh always appends the commit hash as the final segment regardless of how many dashes the tag itself has. Co-Authored-By: Claude Opus 4.8 --- examples/companion_radio/ui-new/UITask.cpp | 7 +++++-- examples/companion_radio/ui-orig/UITask.cpp | 7 ++++--- examples/companion_radio/ui-tiny/UITask.cpp | 7 ++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index f285cfe0..28b93626 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -54,9 +54,12 @@ public: strncpy(_version_info, MESHCORE_VERSION, sizeof(_version_info) - 1); _version_info[sizeof(_version_info) - 1] = '\0'; - // Solo firmware version: strip commit hash suffix (v1.15-solo.1-abcdef -> v1.15) + // Solo firmware version: strip the commit-hash suffix build.sh always + // appends as the LAST dash-segment (v1.15-solo.1-abcdef -> v1.15-solo.1). + // Must be the last dash, not the first: a tag like v1.21-rc1 has a dash + // of its own before the commit hash gets appended. const char *ver = FIRMWARE_VERSION; - const char *dash = strchr(ver, '-'); + const char *dash = strrchr(ver, '-'); int plen = dash ? (int)(dash - ver) : (int)strlen(ver); if (plen >= (int)sizeof(_solo_ver)) plen = sizeof(_solo_ver) - 1; memcpy(_solo_ver, ver, plen); diff --git a/examples/companion_radio/ui-orig/UITask.cpp b/examples/companion_radio/ui-orig/UITask.cpp index f35985fa..eee990f0 100644 --- a/examples/companion_radio/ui-orig/UITask.cpp +++ b/examples/companion_radio/ui-orig/UITask.cpp @@ -43,10 +43,11 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no _display->turnOn(); } - // strip off dash and commit hash by changing dash to null terminator - // e.g: v1.2.3-abcdef -> v1.2.3 + // strip off the commit-hash suffix build.sh always appends as the LAST + // dash-segment, e.g: v1.2.3-abcdef -> v1.2.3, v1.21-rc1-abcdef -> v1.21-rc1 + // (must use the last dash, not the first, since a tag itself may contain one) char *version = strdup(FIRMWARE_VERSION); - char *dash = strchr(version, '-'); + char *dash = strrchr(version, '-'); if (dash) { *dash = 0; } diff --git a/examples/companion_radio/ui-tiny/UITask.cpp b/examples/companion_radio/ui-tiny/UITask.cpp index 0119475e..26445e73 100644 --- a/examples/companion_radio/ui-tiny/UITask.cpp +++ b/examples/companion_radio/ui-tiny/UITask.cpp @@ -39,10 +39,11 @@ class SplashScreen : public UIScreen { public: SplashScreen(UITask* task) : _task(task) { - // strip off dash and commit hash by changing dash to null terminator - // e.g: v1.2.3-abcdef -> v1.2.3 + // strip off the commit-hash suffix build.sh always appends as the LAST + // dash-segment, e.g: v1.2.3-abcdef -> v1.2.3, v1.21-rc1-abcdef -> v1.21-rc1 + // (must use the last dash, not the first, since a tag itself may contain one) const char *ver = FIRMWARE_VERSION; - const char *dash = strchr(ver, '-'); + const char *dash = strrchr(ver, '-'); int len = dash ? dash - ver : strlen(ver); if (len >= sizeof(_version_info)) len = sizeof(_version_info) - 1;