added in delete of pkg on transfer
This commit is contained in:
parent
1116647ec2
commit
75aa177430
@ -282,8 +282,43 @@ if [ -e archivefilename ] ; then git rm archivefilename $QUIET ; fi
|
|||||||
git commit -m "rename-e-smith-pkg script (#12359)" $QUIET
|
git commit -m "rename-e-smith-pkg script (#12359)" $QUIET
|
||||||
git push origin &> /dev/null
|
git push origin &> /dev/null
|
||||||
|
|
||||||
# Transfer back into the source organisation
|
# Do we want to transfer the new package into the source organisation
|
||||||
if [ $TRANSFER ] ; then
|
if [ $TRANSFER ] ; then
|
||||||
|
#Check that target package does not exist
|
||||||
|
if [ $DEBUG ] ; then echo "Check if $SORCEORG/$TARGETPKG is there!" ; fi
|
||||||
|
RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$SOURCEORG/$TARGETPKG")
|
||||||
|
EXISTS=
|
||||||
|
if [ "$RESPONSE" == "200" ]; then
|
||||||
|
EXISTS=true
|
||||||
|
if [ $DEBUG ] ; then echo "Repository for $SOURCEORG/$TARGETPKG exists!" ; fi
|
||||||
|
if [ -z ${DELETEIT} ] ; then
|
||||||
|
while true; do
|
||||||
|
read -p "$SOURCEORG/$TARGETPKG exists! Do you wish to delete it and continue?(y/n) " yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]* )
|
||||||
|
DELETEIT=true
|
||||||
|
break ;;
|
||||||
|
[Nn]* )
|
||||||
|
DELETEIT=
|
||||||
|
break ;;
|
||||||
|
* ) echo "Please answer yes or no.";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ $DELETEIT ] ; then
|
||||||
|
if [ $DEBUG ] ; then echo "Deleting $TARGETORG/$TARGETPKG" ; fi
|
||||||
|
RESPONSE=$(curl "$checkSSL" "$SILENT" -X 'DELETE' \
|
||||||
|
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $GITEAACCESSTOKEN" )
|
||||||
|
EXISTS=
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ $DEBUG ] ; then echo "Repository for $SOURCEORG/$TARGETPKG does not exist on $GITEAHOST" ; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Transfer the package back to source organisation
|
||||||
|
if [[ -z $EXISTS ]] ; then
|
||||||
RESPONSE=$(curl "$SILENT" "$checkSSL" -o /dev/null -w "%{http_code}" -X 'POST' \
|
RESPONSE=$(curl "$SILENT" "$checkSSL" -o /dev/null -w "%{http_code}" -X 'POST' \
|
||||||
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG/transfer" \
|
"$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG/transfer" \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
@ -293,14 +328,16 @@ if [ $TRANSFER ] ; then
|
|||||||
"new_owner": "'"$SOURCEORG"'"
|
"new_owner": "'"$SOURCEORG"'"
|
||||||
}'
|
}'
|
||||||
)
|
)
|
||||||
if [[ $RESPONSE != "202" ]] ; then
|
fi
|
||||||
echo "Unable to transfer $TARGETORG/$TARGETPKG back to $SOURCEORG - Aborting!"
|
if [[ $EXISTS || $RESPONSE != "202" ]] ; then
|
||||||
|
echo "Unable to transfer $TARGETORG/$TARGETPKG to $SOURCEORG/$TARGETPKG ($RESPONSE) - Aborting!"
|
||||||
echo "But everything else has been done and $TARGETORG/$TARGETPKG should be complete."
|
echo "But everything else has been done and $TARGETORG/$TARGETPKG should be complete."
|
||||||
exit 1
|
exit 1
|
||||||
|
else
|
||||||
|
if [[ -z $NOOUTPUT ]] ; then echo "$SOURCEORG/$SOURCEPKG has been renamed as $SOURCEORG/$TARGETPKG" ; fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if [[ -z $NOOUTPUT ]] ; then echo "$SOURCEORG/$SOURCEPKG has been renamed as $TARGETORG/$TARGETPKG" ; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $NOOUTPUT ]] ; then
|
|
||||||
echo "$SOURCEORG/$SOURCEPKG has been renamed as $TARGETORG/$TARGETPKG"
|
|
||||||
fi
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user