diff --git a/src/build.sh b/src/build.sh index 209156db162f69e375ed72d2736c98ea72ce06aa..eca2ccbec4a5e5982e8bfc4b8a8951699da7192b 100755 --- a/src/build.sh +++ b/src/build.sh @@ -163,16 +163,24 @@ 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 + git reset --hard HEAD + git clean -fd cd ../.. fi @@ -184,6 +192,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