Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8cb3a0b6 authored by Jackeagle's avatar Jackeagle Committed by Jackeagle
Browse files

build-community.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.

Signed-off-by: default avatarJackeagle <jackeagle102@gmail.com>
parent 215dd01a
Loading
Loading
Loading
Loading
+16 −8
Original line number Original line Diff line number Diff line
@@ -144,18 +144,26 @@ for branch in ${BRANCH_NAME//,/ }; do
    done
    done


    echo ">> [$(date)] (Re)initializing branch repository" | tee -a "$repo_log"
    echo ">> [$(date)] (Re)initializing branch repository" | tee -a "$repo_log"

    if [ "$LOCAL_MIRROR" = true ]; then
    if [ "$LOCAL_MIRROR" = true ]; then
      yes | repo init -u "$REPO" --reference "$MIRROR_DIR" -b "$branch" &>>"$repo_log"
        repo_cmd="yes | repo init -u \"$REPO\" --reference \"$MIRROR_DIR\" -b \"$branch\""
    else
    else
        TAG_PREFIX=""
        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 is a tag on e/os/releases, prefix with refs/tags/ for 'repo init'"
        # Fetch all tags and check for an exact match
        TAG_MATCH=$(curl -s --fail https://gitlab.e.foundation/api/v4/projects/659/repository/tags?search=${BRANCH_NAME} | jq -r ".[].name" | grep -Fx "${BRANCH_NAME}")

        if [ -n "$TAG_MATCH" ]; then
            echo ">> [$(date)] Branch name $branch is a tag on e/os/releases, prefixing with refs/tags/ for 'repo init'" | tee -a "$repo_log"
            TAG_PREFIX="refs/tags/"
            TAG_PREFIX="refs/tags/"
        fi
        fi
      echo "repo init -u $REPO -b ${TAG_PREFIX}$branch"

      yes | repo init -u "$REPO" -b "${TAG_PREFIX}$branch" &>>"$repo_log"
        repo_cmd="yes | repo init -u \"$REPO\" -b \"${TAG_PREFIX}$branch\""
    fi
    fi


    echo ">> [$(date)] Running: $repo_cmd" | tee -a "$repo_log"
    eval "$repo_cmd" &>>"$repo_log" || { echo ">> [$(date)] ERROR: Failed to initialize repository" | tee -a "$repo_log"; exit 1; }

    # Copy local manifests to the appropriate folder in order take them into consideration
    # Copy local manifests to the appropriate folder in order take them into consideration
    echo ">> [$(date)] Copying '$LMANIFEST_DIR/*.xml' to '.repo/local_manifests/'"
    echo ">> [$(date)] Copying '$LMANIFEST_DIR/*.xml' to '.repo/local_manifests/'"
    mkdir -p .repo/local_manifests
    mkdir -p .repo/local_manifests