diff --git a/build-community.sh b/build-community.sh index 6060acea04242e846e7208ff35d9f45099792521..1b4ac01ee6337bf5d72dbe176f7ef7f584e4e7d6 100755 --- a/build-community.sh +++ b/build-community.sh @@ -144,18 +144,26 @@ for branch in ${BRANCH_NAME//,/ }; do done echo ">> [$(date)] (Re)initializing branch repository" | tee -a "$repo_log" + 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 - 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'" - TAG_PREFIX="refs/tags/" - fi + TAG_PREFIX="" + + # 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}") - yes | repo init -u "$REPO" -b "${TAG_PREFIX}$branch" &>>"$repo_log" + 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/" + fi + + repo_cmd="yes | repo init -u \"$REPO\" -b \"${TAG_PREFIX}$branch\"" 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 echo ">> [$(date)] Copying '$LMANIFEST_DIR/*.xml' to '.repo/local_manifests/'" mkdir -p .repo/local_manifests