From e5b96d2ee041a880f94bcb5e07a3cb8439220d05 Mon Sep 17 00:00:00 2001 From: "Rich O." Date: Wed, 28 Oct 2026 22:00:48 -0400 Subject: [PATCH] Add upstream commits since the tag to the -hz build identifier Builds on newer upstream code kept the same -hz.N label because N counted only local commits, so KM-Test's v1.18.0.2-hz.1 and the CI release of a later upstream were indistinguishable. The identifier is now -hz.U.L: U upstream commits past the version tag, L local firmware-code commits. --- local_build.sh | 18 +++++++++++++----- local_version.py | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/local_build.sh b/local_build.sh index ff30faeb4..73d66f912 100755 --- a/local_build.sh +++ b/local_build.sh @@ -68,9 +68,12 @@ cd "$(dirname "$0")" # VERSION follows the fork's own numbering: the highest vX.Y.Z.W tag reachable # from HEAD (e.g. v1.17.1.10 from rak4631-full-companion-v1.17.1.10-preview3). # Local code changes add an identifier; build settings (untracked files) don't: -# -hz.N N of your own commits that change firmware code relative to the -# maintainer's fork (upstream/keymindCascade; origin is the personal -# Gitea copy, so @{upstream} would hide them) +# -hz.U.L U upstream commits past the vX.Y.Z.W tag(s) in the maintainer's fork +# (upstream/keymindCascade; origin is the personal Gitea copy, so +# @{upstream} would hide them) and L of your own commits that change +# firmware code. U grows with every upstream pull, so builds on newer +# upstream code sort higher even when the tag and L are unchanged. +# LoRa OTA sees only vX.Y.Z.W; compare U.L to decide an upgrade. # .dirty uncommitted edits to tracked firmware code # Merge commits and the build-setup files below don't count: they change # settings, not code. Edit LOCAL_FW_SETUP_PATHS if you add more setup files. @@ -90,8 +93,13 @@ LOCAL_FW_SETUP_PATHS=":(exclude)local_build.sh :(exclude)local_version.py :(excl # shellcheck disable=SC2086 # intentional word-splitting of the pathspec list local_commits=$(git rev-list --count --no-merges "${LOCAL_FW_UPSTREAM_REF}..HEAD" \ -- . $LOCAL_FW_SETUP_PATHS 2>/dev/null || echo 0) -if [ "$local_commits" -gt 0 ]; then - local_id="-hz.${local_commits}" +# Every tag carrying this version is excluded, so U counts from the newest of them. +upstream_base=$(git merge-base HEAD "${LOCAL_FW_UPSTREAM_REF}" 2>/dev/null || git rev-parse HEAD) +# shellcheck disable=SC2046 # one ^tag argument per tag +upstream_commits=$(git rev-list --count "$upstream_base" \ + $(git tag --merged "$upstream_base" | grep -F "v${fork_version}" | sed 's/^/^/') 2>/dev/null || echo 0) +if [ "$upstream_commits" -gt 0 ] || [ "$local_commits" -gt 0 ]; then + local_id="-hz.${upstream_commits}.${local_commits}" fi # shellcheck disable=SC2086 if [ -n "$(git status --porcelain --untracked-files=no -- . $LOCAL_FW_SETUP_PATHS)" ]; then diff --git a/local_version.py b/local_version.py index fbd6c069f..cd6a84079 100644 --- a/local_version.py +++ b/local_version.py @@ -4,7 +4,7 @@ # # repeater/room/sensor: hazelwood_repeater v1.17.1.10 (core v1.17.1) # companion: v1.17.1.10 hazelwood (core v1.17.1) -# with local code changes the version gains -hz.N and/or .dirty (local_build.sh) +# past the tag the version gains -hz.U.L and/or .dirty (local_build.sh) # # Companions keep the version first because the app's device-info frame # carries only the first 19 characters (companion MyMesh.cpp strzcpy(..., 20)).