Add .gitignore and enhance Gitea mirror script for repo visibility updates

This commit is contained in:
2026-08-18 16:07:12 +03:00
parent 2e3ef4e132
commit 1bdc15b258
2 changed files with 40 additions and 2 deletions
+18
View File
@@ -0,0 +1,18 @@
# OS
.DS_Store
Thumbs.db
# Editor
.vscode/
.idea/
*.swp
*.swo
# Env / secrets — never commit real tokens
.env
.env.*
!.env.example
# Logs / temp
*.log
/tmp/
+22 -2
View File
@@ -33,12 +33,32 @@ echo "$repos_json" | jq -c '.[] | {name, private}' | while read -r entry; do
echo "Processing: ${name} (private=${private})"
# Check if it already exists in Gitea
existing_status=$(curl -s -o /dev/null -w "%{http_code}" \
existing_resp=$(curl -s -w "\n%{http_code}" \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_URL}/api/v1/repos/${GITEA_OWNER}/${name}")
existing_status=$(echo "$existing_resp" | tail -n1)
existing_body=$(echo "$existing_resp" | sed '$d')
if [ "$existing_status" == "200" ]; then
echo " Already mirrored, skipping migration (existing mirror syncs on its own schedule)."
gitea_private=$(echo "$existing_body" | jq -r '.private')
if [ "$gitea_private" != "$private" ]; then
echo " Already mirrored, but visibility differs (GitHub private=${private}, Gitea private=${gitea_private}). Syncing..."
patch_code=$(curl -s -o /tmp/gitea_patch_resp.json -w "%{http_code}" \
-X PATCH "${GITEA_URL}/api/v1/repos/${GITEA_OWNER}/${name}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"private\": ${private}}")
if [ "$patch_code" == "200" ]; then
echo " Visibility updated to private=${private}."
else
echo " Failed to update visibility (HTTP ${patch_code}):"
cat /tmp/gitea_patch_resp.json
fi
else
echo " Already mirrored, visibility already matches (private=${gitea_private}). Skipping."
fi
continue
fi