[PR #266] [MERGED] fix: prevent duplicate issue/PR mirroring, enforce release retention, and fix public repo auth #2124

Closed
opened 2026-05-03 03:05:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/RayLabsHQ/gitea-mirror/pull/266
Author: @arunavo4
Created: 4/13/2026
Status: Merged
Merged: 4/16/2026
Merged by: @arunavo4

Base: mainHead: fix/mirror-sync-bugs-262-263-264


📝 Commits (2)

  • d3ce63b fix: prevent duplicate issue/PR mirroring, enforce release retention, and fix public repo auth (#262, #263, #264)
  • fdf56c6 fix: preserve backup settings in env config loader (#267)

📊 Changes

6 files changed (+120 additions, -20 deletions)

View changed files

📝 src/lib/env-config-loader.ts (+7 -0)
📝 src/lib/gitea-enhanced.test.ts (+4 -3)
📝 src/lib/gitea-enhanced.ts (+21 -2)
📝 src/lib/gitea.ts (+75 -5)
📝 src/lib/utils/mirror-source-auth.test.ts (+7 -7)
📝 src/lib/utils/mirror-source-auth.ts (+6 -3)

📄 Description

Summary

Fixes three reported mirror sync bugs:

  • #262 — Duplicate issues/PRs created on every sync: Added !metadataState.components.issues and !metadataState.components.pullRequests guards to syncGiteaRepoEnhanced, matching the existing pattern used by labels and milestones. Without these guards, every sync re-mirrored all issues/PRs, creating duplicates that compounded over time. Users can still re-trigger via "Re-run Metadata" which resets the metadata state.

  • #264 — Release retention limit not enforced: Two fixes:

    1. Changed httpPuthttpPatch for Gitea release updates — the Gitea/Forgejo API uses PATCH, not PUT, causing silent HTTP 405 errors on every release update.
    2. Added paginated release retention cleanup that counts all Gitea releases and deletes the oldest excess ones to enforce the configured releaseLimit.
  • #263 — Repos not syncing after initial mirror (Forgejo): Removed the if (repository.isPrivate) guard around buildGithubSourceAuthPayload so auth credentials are always sent during migration. This prevents Forgejo's "terminal prompts disabled" error on subsequent fetches for public repos. Also added missing service: "git" to the org migration payload for consistency.

Supporting changes

  • buildGithubSourceAuthPayload now returns {} instead of throwing when token is missing, allowing unconditional use
  • Added NOTE comment in syncGiteaRepoEnhanced documenting that Gitea/Forgejo's PATCH repo API does not support updating mirror credentials — repos migrated without credentials must be deleted and re-mirrored

Test plan

  • All 231 existing tests pass (0 failures)
  • Updated test for metadata guard behavior (now expects skip instead of re-mirror)
  • Updated test for buildGithubSourceAuthPayload (expects {} return instead of throw)
  • Verify on a Gitea/Forgejo instance that issue mirroring only runs once per repo
  • Verify release updates no longer return HTTP 405
  • Verify release count is trimmed to releaseLimit after sync
  • Verify newly mirrored public repos sync correctly on Forgejo

Closes #262, closes #263, closes #264


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/RayLabsHQ/gitea-mirror/pull/266 **Author:** [@arunavo4](https://github.com/arunavo4) **Created:** 4/13/2026 **Status:** ✅ Merged **Merged:** 4/16/2026 **Merged by:** [@arunavo4](https://github.com/arunavo4) **Base:** `main` ← **Head:** `fix/mirror-sync-bugs-262-263-264` --- ### 📝 Commits (2) - [`d3ce63b`](https://github.com/RayLabsHQ/gitea-mirror/commit/d3ce63b7c39f50f6587aba0fdcf2832b30e16811) fix: prevent duplicate issue/PR mirroring, enforce release retention, and fix public repo auth (#262, #263, #264) - [`fdf56c6`](https://github.com/RayLabsHQ/gitea-mirror/commit/fdf56c626286a25ddbf24df1620c4ac423a26073) fix: preserve backup settings in env config loader (#267) ### 📊 Changes **6 files changed** (+120 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/env-config-loader.ts` (+7 -0) 📝 `src/lib/gitea-enhanced.test.ts` (+4 -3) 📝 `src/lib/gitea-enhanced.ts` (+21 -2) 📝 `src/lib/gitea.ts` (+75 -5) 📝 `src/lib/utils/mirror-source-auth.test.ts` (+7 -7) 📝 `src/lib/utils/mirror-source-auth.ts` (+6 -3) </details> ### 📄 Description ## Summary Fixes three reported mirror sync bugs: - **#262 — Duplicate issues/PRs created on every sync:** Added `!metadataState.components.issues` and `!metadataState.components.pullRequests` guards to `syncGiteaRepoEnhanced`, matching the existing pattern used by labels and milestones. Without these guards, every sync re-mirrored all issues/PRs, creating duplicates that compounded over time. Users can still re-trigger via "Re-run Metadata" which resets the metadata state. - **#264 — Release retention limit not enforced:** Two fixes: 1. Changed `httpPut` → `httpPatch` for Gitea release updates — the Gitea/Forgejo API uses PATCH, not PUT, causing silent HTTP 405 errors on every release update. 2. Added paginated release retention cleanup that counts all Gitea releases and deletes the oldest excess ones to enforce the configured `releaseLimit`. - **#263 — Repos not syncing after initial mirror (Forgejo):** Removed the `if (repository.isPrivate)` guard around `buildGithubSourceAuthPayload` so auth credentials are always sent during migration. This prevents Forgejo's "terminal prompts disabled" error on subsequent fetches for public repos. Also added missing `service: "git"` to the org migration payload for consistency. ### Supporting changes - `buildGithubSourceAuthPayload` now returns `{}` instead of throwing when token is missing, allowing unconditional use - Added NOTE comment in `syncGiteaRepoEnhanced` documenting that Gitea/Forgejo's PATCH repo API does not support updating mirror credentials — repos migrated without credentials must be deleted and re-mirrored ## Test plan - [x] All 231 existing tests pass (0 failures) - [x] Updated test for metadata guard behavior (now expects skip instead of re-mirror) - [x] Updated test for `buildGithubSourceAuthPayload` (expects `{}` return instead of throw) - [ ] Verify on a Gitea/Forgejo instance that issue mirroring only runs once per repo - [ ] Verify release updates no longer return HTTP 405 - [ ] Verify release count is trimmed to `releaseLimit` after sync - [ ] Verify newly mirrored public repos sync correctly on Forgejo Closes #262, closes #263, closes #264 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-03 03:05:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea-mirror#2124