From db654811be2d249bd0498d64ebb5c27dbeae05f7 Mon Sep 17 00:00:00 2001 From: Jackeagle <116548-Jackeagle@users.noreply.gitlab.e.foundation> Date: Tue, 11 Feb 2025 03:17:04 +0000 Subject: [PATCH 1/2] build.sh: Fixed incorrect tag detection logic in repo init. - Previously, the API search used substring matching, causing false positives (e.g., 'a14' incorrectly matched 'v2.8-beta.2-a14'). - Now, we fetch all tags and use exact matching (`grep -Fx`) to determine if BRANCH_NAME is a tag. --- src/build.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/build.sh b/src/build.sh index 209156d..e8429eb 100755 --- a/src/build.sh +++ b/src/build.sh @@ -163,13 +163,20 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then echo ">> [$(date)] (Re)initializing branch repository" TAG_PREFIX="" - if curl -s https://gitlab.e.foundation/api/v4/projects/659/repository/tags?search=${BRANCH_NAME} | jq -r ".[].name" | grep -q ${BRANCH_NAME}; then - echo ">> [$(date)] Branch name ${BRANCH_NAME} is a tag on e/os/releases, prefix with refs/tags/ for 'repo init'" - TAG_PREFIX="refs/tags/" + + # Fetch all tags and check for an exact match + TAG_MATCH=$(curl -s --fail https://gitlab.e.foundation/api/v4/projects/659/repository/tags | jq -r ".[].name" | grep -Fx "$BRANCH_NAME") + + if [ -n "$TAG_MATCH" ]; then + echo ">> [$(date)] Branch name $BRANCH_NAME is a tag on e/os/releases, prefixing with refs/tags/ for 'repo init'" + TAG_PREFIX="refs/tags/" fi + if [ -n ${REPO_INIT_DEPTH} ] && [ ${REPO_INIT_DEPTH} -gt 0 ]; then REPO_INIT_PARAM="--depth ${REPO_INIT_DEPTH}" fi + + # Reset the default manifest if it exists if [ -f ".repo/manifests/default.xml" ]; then cd .repo/manifests/ git checkout default.xml @@ -184,6 +191,7 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then fi # Repo init source + echo ">> [$(date)] Running: repo init $REPO_INIT_PARAM -u \"$REPO\" -b \"${TAG_PREFIX}${BRANCH_NAME}\" $REPO_GROUPS" yes | repo init $REPO_INIT_PARAM -u "$REPO" -b "${TAG_PREFIX}${BRANCH_NAME}" $REPO_GROUPS if [ "$REPO_CUSTOM_MANIFEST" != false ]; then -- GitLab From 67ac7f29aea7bf1055879dfdc7e2593ecb0a16a2 Mon Sep 17 00:00:00 2001 From: Jackeagle <116548-Jackeagle@users.noreply.gitlab.e.foundation> Date: Tue, 11 Feb 2025 05:04:58 +0000 Subject: [PATCH 2/2] build.sh: Ensure a clean reset of the default manifest before repo init --- src/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/build.sh b/src/build.sh index e8429eb..eca2ccb 100755 --- a/src/build.sh +++ b/src/build.sh @@ -179,7 +179,8 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then # Reset the default manifest if it exists if [ -f ".repo/manifests/default.xml" ]; then cd .repo/manifests/ - git checkout default.xml + git reset --hard HEAD + git clean -fd cd ../.. fi -- GitLab