diff --git a/git-cvs2git.sh b/git-cvs2git.sh index b090947..c985787 100755 --- a/git-cvs2git.sh +++ b/git-cvs2git.sh @@ -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) +# will use parameters set for local repository else it will use remote +# turn on debug regardless of ~/.smegit/config +# 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 []" 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!"