From ef23cc5f9a34edb75de17669de664f8cea357ca3 Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Mon, 5 Jun 2023 14:54:51 +1000 Subject: [PATCH] capture fail of migrate --- rename-e-smith-pkg.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rename-e-smith-pkg.sh b/rename-e-smith-pkg.sh index 21eee15..f3dfbb2 100755 --- a/rename-e-smith-pkg.sh +++ b/rename-e-smith-pkg.sh @@ -162,8 +162,8 @@ if [[ "$SOURCEORG" == "smecontribs" ]]; then fi # migrate the source package over to target with updated fields -if [ $DEBUG ] ; then echo "Migrating $SOURCEORG/$SOURCEPKG as $TARGETORG/$TRAGETPKG on $GITEAHOST" ; fi -RESPONSE=$(curl $SILENT $checkSSL -X 'POST' \ +if [ $DEBUG ] ; then echo "Migrating $SOURCEORG/$SOURCEPKG as $TARGETORG/$TARGETPKG on $GITEAHOST" ; fi +RESPONSE=$(curl $SILENT $checkSSL -o /dev/null -w "%{http_code}" -X 'POST' \ "$GITEAHOST/api/v1/repos/migrate" \ -H 'accept: application/json' \ -H "Authorization: token $GITEAACCESSTOKEN" \ @@ -176,6 +176,10 @@ RESPONSE=$(curl $SILENT $checkSSL -X 'POST' \ "repo_owner": "'"$TARGETORG"'" }' ) +if [[ $RESPONSE != 201 ]] ; then + echo "Unable to migrate $SOURCEORG/$SOURCEPKG to $TARGETORG/$TARGETPKG ($RESPOMNSE) - Aborting" + exit 1 +fi # Migrate does NOT copy accross the issues and wiki external links # grab WIKILINK from source package @@ -325,7 +329,7 @@ if [ $TRANSFER ] ; then # Transfer the package back to source organisation if [[ -z $EXISTS ]] ; then - if [ $DEBUG ] ; then echo "Acrtual Transfer" ; fi + if [ $DEBUG ] ; then echo "Actual Transfer" ; fi RESPONSE=$(curl "$SILENT" "$checkSSL" -o /dev/null -w "%{http_code}" -X 'POST' \ "$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG/transfer" \ -H 'accept: application/json' \