add 4-04 check on repo delete

This commit is contained in:
Trevor Batley 2023-06-02 16:27:46 +10:00
parent 08f624fd4d
commit 51551534f1

View File

@ -2,7 +2,10 @@
#
# $1 = Module name e.g. smeserver-ddclient
# $2 = Organisation (smeserver or smecontrib)e
# $3 = "local" will use parameters set for local repository else it will use remote
# optional (can be in any order)
# <local> will use parameters set for local repository else it will use remote
# <debug> turn on debug regardless of ~/.smegit/config
# <noisy> print a line showing how it was called
# This works whether the repo and local files exist of not (it deletes them if necessary)
# However if the remote repo exists, it preserves the README.md file so that edits are not lost
# Also note: I have had difficulty deleting all the link files in the source tree!
@ -12,12 +15,6 @@ if [[ -z $1 ]] ; then
echo "************git-cvs2git.sh <modulename> <organization> [<local>]"
exit 0
fi
clear
echo "**************************************************************************************************"
echo "* *"
echo "* SMEServer - git-cvs2git $1 $2 $3 `date` *"
echo "* *"
echo "**************************************************************************************************"
#
# Pull in parameters from a config file ~/.smegit/config
@ -51,6 +48,32 @@ done < "$inifilename"
DEBUG=
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
GITEAUser=${remote_USER}
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
GITEAHOST=${remote_GITEAHOST}
NOISY=
EXTRAPARAMS=
for param in $3 $4 $5 $6; do
if [ $param ] ; then
case $param in
local )
GITEAUser=${local_USER}
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
GITEAHOST=${local_GITEAHOST}
;;
debug )
DEBUG=true ;;
noisy )
NOISY=true ;;
* )
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
esac
else
break
fi
done
if [ $NOISY ] ; then echo "git-cvs2git.sh $1 $2 $3 $4 $5 $6" ; fi
if [ $DEBUG ] ; then echo "************found ini file: $inifilename" ; fi
# Make this null if you want lots of output. Still quite a bit anyway
QUIET="-q"
@ -73,16 +96,6 @@ else
WORKDIR=${smegit_WORKDIR}
fi
if [ $DEBUG ] ; then echo "WORKDIR=$WORKDIR" ; fi
GITEAUser=${remote_USER}
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
GITEAHOST=${remote_GITEAHOST}
if [ $3 ] ; then
if [ $3 == "local" ] ; then
GITEAUser=${local_USER}
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
GITEAHOST=${local_GITEAHOST}
fi
fi
RemoteRepoURL="$GITEAHOST/$2/$1"
#
@ -270,7 +283,7 @@ RESPONSE=$(curl "$checkSSL" "$curlsilent" -X 'DELETE' \
"$GITEAHOST/api/v1/repos/$ORGGITEA/$1" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN")
if [[ $RESPONSE == "204" ]] ; then
if [[ $RESPONSE == "204" || $RESPONSE == "404" ]] ; then
if [ $DEBUG ] ; then echo "************Repository $ORGGITEA/$1 deleted or does not exist" ; fi
else
echo "************Can NOT delete Repository $ORGGITEA/$1 - results will be unknown - Aborting!"