From 017c699c630847bf4b0b2da080c48ad9af1fffe5 Mon Sep 17 00:00:00 2001 From: Daiane Angolini Date: Fri, 27 Mar 2026 16:03:59 -0300 Subject: [PATCH] helpers: Decide LMP_VERSION by branch instead of HEAD Instead of always searching for the latest tag from main, first detect which branch was initialized by repo and then fetch the latest tag. Signed-off-by: Daiane Angolini --- helpers.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/helpers.sh b/helpers.sh index c5acc749..85d1b5ea 100644 --- a/helpers.sh +++ b/helpers.sh @@ -115,9 +115,22 @@ function set_base_lmp_version { git remote set-url origin https://github.com/foundriesio/lmp-manifest git fetch origin --tags --quiet - # 3: Find our base LMP version based on the HEAD - export LMP_VERSION=$(git describe --tags --abbrev=0 HEAD) - export LMP_VERSION_MINOR="$(git rev-list ${LMP_VERSION}..HEAD --count)" + # 3: Find our base LMP version based on the branch + # repo always checks out manifests.git on a local branch named 'default' + # regardless of the actual remote branch; resolve the real branch via tracking config + _local_branch=$(git rev-parse --abbrev-ref HEAD) + MANIFEST_BRANCH=$(git config branch.${_local_branch}.merge 2>/dev/null | sed 's|refs/heads/||') + if [ -z "$MANIFEST_BRANCH" ] ; then + # detached HEAD or no tracking info — fall back to the checked-out commit + LMP_REF=HEAD + MANIFEST_BRANCH="${_local_branch} (no tracking)" + else + git fetch origin "$MANIFEST_BRANCH" --quiet + LMP_REF="refs/remotes/origin/${MANIFEST_BRANCH}" + fi + status "Detecting LmP version from branch: ${MANIFEST_BRANCH} (ref: ${LMP_REF})" + export LMP_VERSION=$(git describe --tags --abbrev=0 $LMP_REF) + export LMP_VERSION_MINOR="$(git rev-list ${LMP_VERSION}..${LMP_REF} --count)" export LMP_VERSION_CACHE="$(echo $LMP_VERSION | sed 's/\.[0-9]*$//')" if [[ "${H_PROJECT}" == "lmp" ]] || [ -v LMP_VERSION_CACHE_DEV ] ; then # Public LmP build - we are building for the *next* release