diff --git a/rename-e-smith-pkg.sh b/rename-e-smith-pkg.sh index 944eca8..2a063d2 100755 --- a/rename-e-smith-pkg.sh +++ b/rename-e-smith-pkg.sh @@ -64,6 +64,11 @@ else WORKDIR=${smegit_WORKDIR} fi +# Command line parameters +#Extract +SOURCEPKG=$1 +TARGETPKG=${SOURCEPKG/e-smith/smeserver} + GITEAHOST=${remote_GITEAHOST} GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN} SOURCEORG="smeserver" @@ -93,6 +98,7 @@ for param in $2 $3 $4 $5 $6; do break fi done +TARGETORG=$SOURCEORG # Debug settings # Make this null if you want lots of output. Still quite a bit anyway QUIET="--quiet" @@ -104,10 +110,6 @@ fi # Make this null to get curl to check ssl cert checkSSL="-k" -#Extract -SOURCEPKG=$1 -TARGETPKG=${SOURCEPKG/e-smith/smeserver} - #Check that source package exists if [ $DEBUG ] ; then echo "Check if $SOURCEORG/$SOURCEPKG is there!" ; fi RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$SOURCEORG/$SOURCEPKG") @@ -282,7 +284,7 @@ git push origin &> /dev/null # Transfer back into the source organisation if [ $TRANSFER ] ; then - curl "$SILENT" -X 'POST' \ + RESPONSE=$(curl "$SILENT" -X 'POST' \ "$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG/transfer" \ -H 'accept: application/json' \ -H "Authorization: token $GITEAACCESSTOKEN" \ @@ -290,6 +292,12 @@ if [ $TRANSFER ] ; then -d '{ "new_owner": "'"$SOURCEORG"'" }' + ) + if [[ $RESPONSE != "202" ]] ; then + echo "Unable to transfer $TARGETORG/$TARGETPKG back to $SOURCEORG - Aborting!" + echo "But everything else has been done and $TARGETORG/$TARGETPKG should be complete." + exit 1 + fi fi if [[ -z $NOOUTPUT ]] ; then