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

Commit db654811 authored by Jackeagle's avatar Jackeagle
Browse files

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.
parent f3c59af2
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -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'"

  # 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