do it all in the same org

This commit is contained in:
Trevor Batley 2023-06-05 09:42:48 +10:00
parent 901042b562
commit 96f7295f96

View File

@ -64,6 +64,11 @@ else
WORKDIR=${smegit_WORKDIR} WORKDIR=${smegit_WORKDIR}
fi fi
# Command line parameters
#Extract <pkg>
SOURCEPKG=$1
TARGETPKG=${SOURCEPKG/e-smith/smeserver}
GITEAHOST=${remote_GITEAHOST} GITEAHOST=${remote_GITEAHOST}
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN} GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
SOURCEORG="smeserver" SOURCEORG="smeserver"
@ -93,6 +98,7 @@ for param in $2 $3 $4 $5 $6; do
break break
fi fi
done done
TARGETORG=$SOURCEORG
# Debug settings # Debug settings
# Make this null if you want lots of output. Still quite a bit anyway # Make this null if you want lots of output. Still quite a bit anyway
QUIET="--quiet" QUIET="--quiet"
@ -104,10 +110,6 @@ fi
# Make this null to get curl to check ssl cert # Make this null to get curl to check ssl cert
checkSSL="-k" checkSSL="-k"
#Extract <pkg>
SOURCEPKG=$1
TARGETPKG=${SOURCEPKG/e-smith/smeserver}
#Check that source package exists #Check that source package exists
if [ $DEBUG ] ; then echo "Check if $SOURCEORG/$SOURCEPKG is there!" ; fi 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") 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 # Transfer back into the source organisation
if [ $TRANSFER ] ; then if [ $TRANSFER ] ; then
curl "$SILENT" -X 'POST' \ RESPONSE=$(curl "$SILENT" -X 'POST' \
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG/transfer" \ "$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG/transfer" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \ -H "Authorization: token $GITEAACCESSTOKEN" \
@ -290,6 +292,12 @@ if [ $TRANSFER ] ; then
-d '{ -d '{
"new_owner": "'"$SOURCEORG"'" "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 fi
if [[ -z $NOOUTPUT ]] ; then if [[ -z $NOOUTPUT ]] ; then