diff --git a/git-cvs2git.sh b/git-cvs2git.sh index c985787..ea15328 100755 --- a/git-cvs2git.sh +++ b/git-cvs2git.sh @@ -233,6 +233,7 @@ fi # See if it exists on the Gitea host REPO_NAME=$1 if [ $DEBUG ] ; then echo "check that $GITEAHOST/$ORGGITEA/$REPO_NAME exists" ; fi +READMECONTENTS= RESPONSE=$(curl $checkSSL $curlsilent -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$REPO_NAME") if [ "$RESPONSE" == "200" ]; then if [ $DEBUG ] ; then echo "************Repository for $1 already exists!" ; fi @@ -240,33 +241,33 @@ if [ "$RESPONSE" == "200" ]; then # And Clone it if [ $DEBUG ] ; then echo "git clone $GITEAHOST/$ORGGITEA/$1.git" ; fi cd $GITFiles - git clone "$GITEAHOST/$ORGGITEA/$1.git" - #GIT_SSL_NO_VERIFY=true git clone "$GITEAHOST/$ORGGITEA/$1.git" - NOREPO=0 -else - if [ $DEBUG ] ; then echo "************Repository for $1 does not exist." ; fi - NOREPO=1 -fi - -# then pull in the README -READMECONTENTS=""; -cd $GITFiles -if [ -d "$1" ] ; then - cd $GITFiles/$1 - # Retain the contents of the README.md (incase its been editted, and saving multiple GPT accesses) - if [ -f README.md ] ; then + git clone "$GITEAHOST/$ORGGITEA/$1.git" + if [[ -f $GITFILES/$1/README.md]] ; then # Move it and remember its new (temp) name READMECONTENTS=`mktemp` mv -f README.md "$READMECONTENTS" fi - if [ $DEBUG ] ; then echo "************Saved README: $READMECONTENTS" ; fi + # Now delete the repo, re-create it and clone it in to local + if [ $DEBUG ] ; then echo "Delete $ORGGITEA/$1" ; fi + RESPONSE=$(curl "$checkSSL" "$curlsilent" -o /dev/null -w "{%http_code}" -X 'DELETE' \ + "$GITEAHOST/api/v1/repos/$ORGGITEA/$1" \ + -H 'accept: application/json' \ + -H "Authorization: token $GITEAACCESSTOKEN") + if [[ $RESONSE == "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!" + echo "RESPONSE=$RESPONSE" + exit 1 + fi # Delete all files, links and directories if [ $DEBUG ] ; then echo "************Deleting local GIT files" ; fi cd $GITFiles rm -Rf $GITFiles/$1 +else + if [ $DEBUG ] ; then echo "************Repository for $1 does not exist." ; fi fi - cd $GITFiles #git init $QUIET $1 @@ -277,32 +278,8 @@ else PACKAGETYPE="3rd Party (Maintained by Koozali)" fi -# Now delete the repo, re-create it and clone it in to local -if [ $DEBUG ] ; then echo "Delete $ORGGITEA/$1" ; fi -RESPONSE=$(curl "$checkSSL" "$curlsilent" -X 'DELETE' \ - "$GITEAHOST/api/v1/repos/$ORGGITEA/$1" \ - -H 'accept: application/json' \ - -H "Authorization: token $GITEAACCESSTOKEN") -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!" - echo "RESPONSE=$RESPONSE" - exit 1 -fi -# and check if it is here. -if [ $DEBUG ] ; then echo "Check if $ORGGITEA/$1 is there!" ; fi -RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$1") -if [ "$RESPONSE" == "200" ]; then - if [ $DEBUG ] ; then echo "************Repository for $1 exists!" ; fi - GOTREPO=0 -else - if [ $DEBUG ] ; then echo "************Repository for $1 does not exist" ; fi - GOTREPO=1 -fi - # -# Create the repo +# Re-create the repo # if [ $DEBUG ] ; then echo "************Creating repo for $1 $PACKAGETYPE" ; fi RESPONSE=$(curl "$checkSSL" "$curlsilent" -X 'POST' "$GITEAHOST/api/v1/orgs/$ORGGITEA/repos" \