Commit 8a4b2a23 authored by Andreas Tille's avatar Andreas Tille
Browse files

Fix test whether project exists

parent 674934d0
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -41,12 +41,15 @@ fi

# Did we already push to salsa?
set +e
set -x
RESPONSE=$(curl "$SALSA_URL/projects?search=${DEBPKGNAME}")
echo $RESPONSE | jq --exit-status "map(select(.path == \"${DEBPKGNAME}\")) | .[0].id" > /dev/null
set -e
if [ $? -ne 0 ]; then
if [ $? -eq 0 ]; then
    # Seems like not, lets create a project
    set -x
    echo "Project ${DEBPKGNAME} does not exists on Salsa - just create the project"
    echo "ATTENTION: If this fails for you ask for **Maintainer** permissions in your project"
    RESPONSE=$(curl "$SALSA_URL/projects?private_token=$SALSA_TOKEN" \
        --data "path=${DEBPKGNAME}&namespace_id=${SALSA_GROUP_ID}&description=${SHORTDESC}&visibility=public")

@@ -57,6 +60,7 @@ if [ $? -ne 0 ]; then
    set +x
else
    set -x
    echo "Project ${DEBPKGNAME} exists on Salsa - just update some metadata"
    PROJECT_ID=$(echo $RESPONSE | jq "map(select(.path == \"${DEBPKGNAME}\")) | .[0].id")
    set +x
fi
@@ -64,7 +68,7 @@ fi
set +e
git remote show origin
set -e
if [ $? -ne 0 ] ; then
if [ $? -eq 0 ] ; then
    git remote add origin git@salsa.debian.org:${SALSA_GROUP}/${DEBPKGNAME}.git
fi
git push origin master