diff --git a/delete_gitea_org b/delete_gitea_org index 747705d..5c6cbf3 100755 --- a/delete_gitea_org +++ b/delete_gitea_org @@ -66,7 +66,10 @@ fetch_orga_repos() { log "Fetch organization repos." if ! $CURL -X GET $GITEA_URL/api/v1/orgs/${gitea_organization}/repos "${header_options[@]}" >${jsonoutput}/1.json 2>${jsonoutput}/stderr.txt; then local code=$(<${jsonoutput}/result.txt) - if (( code != 404 ));then # 404 == orga not found + if (( code == 404 ));then # 404 == orga not found + log "404: Gitea orga not found. Nothing to do. Exiting." + exit 1 + else cat ${jsonoutput}/stderr.txt >&2 fi fi @@ -95,7 +98,9 @@ delete_orga() { log "Delete orga." if ! $CURL -X DELETE $GITEA_URL/api/v1/orgs/${gitea_organization} "${header_options[@]}" > ${jsonoutput}/result.txt 2>${jsonoutput}/stderr.txt; then local code=$(<${jsonoutput}/result.txt) - if (( code != 404 ));then # 404 == orga not found + if (( code == 404 ));then # 404 == orga not found + log "404: Gitea orga not found. Is it already deleted?" + else cat ${jsonoutput}/stderr.txt >&2 fi fi diff --git a/github2gitea-mirror b/github2gitea-mirror index b268bce..3485681 100755 --- a/github2gitea-mirror +++ b/github2gitea-mirror @@ -163,7 +163,9 @@ create_migration_repo() { log "Create migration repo." if ! $CURL -w "%{http_code}\n" "${header_options[@]}" -d @- -X POST $GITEA_URL/api/v1/repos/migrate > ${jsonoutput}/result.txt 2>${jsonoutput}/stderr.txt; then local code=$(<${jsonoutput}/result.txt) - if (( code != 409 ));then # 409 == repo already exits + if (( code == 409 ));then # 409 == repo already exits + log "409: Gitea repo already exists. Skipping migration." + else cat ${jsonoutput}/stderr.txt >&2 fi fi @@ -175,7 +177,9 @@ create_migration_orga() { log "Create migration orga with name: ${gitea_organization}" if ! $CURL -X POST $GITEA_URL/api/v1/orgs "${header_options[@]}" --data '{"username": "'"${gitea_organization}"'", "visibility": "'"${visibility}"'"}' > ${jsonoutput}/result.txt 2>${jsonoutput}/stderr.txt; then local code=$(<${jsonoutput}/result.txt) - if (( code != 422 ));then # 422 == orga already exits + if (( code == 422 ));then # 422 == orga already exits + log "422: Gitea orga already exists. Skipping creation." + else cat ${jsonoutput}/stderr.txt >&2 fi fi