mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-05-24 00:44:08 -05:00
[PR #287] [MERGED] fix: reconcile metadata on every sync instead of once per repo #2919
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/RayLabsHQ/gitea-mirror/pull/287
Author: @riguettodev
Created: 5/15/2026
Status: ✅ Merged
Merged: 5/16/2026
Merged by: @arunavo4
Base:
main← Head:fix/reconcile-metadata-on-resync📝 Commits (1)
efc3ea0fix: reconcile metadata on every sync instead of once per repo📊 Changes
3 files changed (+40 additions, -124 deletions)
View changed files
📝
src/lib/gitea-enhanced.test.ts(+7 -4)📝
src/lib/gitea-enhanced.ts(+9 -39)📝
src/lib/gitea.ts(+24 -81)📄 Description
Summary
After the first successful sync of a repository, subsequent syncs no longer reconcile metadata (issue/PR titles, bodies, labels, milestones). Changes made on GitHub never propagate to Gitea on re-sync, even though the underlying mirror functions are already designed to perform idempotent upserts via
[GH-ISSUE #N]/[GH-PR #N]markers.The log signature is:
This is a regression: the exact same behavior was the subject of #165 (Jan 2026), which was fixed by #184. The regression was reintroduced by #266.
Root Cause
PR #184 (
Implement incremental issue and PR metadata sync) added marker-based idempotent upserts so re-syncs would update existing entries instead of creating duplicates. That solved #165, where the maintainer wrote:Later, PR #266 (
fix: prevent duplicate issue/PR mirroring, fixes #262) added one-shot guards ingitea.tsandgitea-enhanced.ts:The intent was duplicate prevention, but #184 already handled duplicates via marker-based deduplication. The guard turned a reconciling re-sync into a one-shot mirror, re-introducing the original #165 symptom.
The releases mirror path in the same files (
shouldMirrorReleases) does not have such a guard and runs unconditionally on every sync — that is the correct pattern, and the model this PR aligns the other metadata paths with.Fix
Remove the
!metadataState.components.Xguards insrc/lib/gitea.tsandsrc/lib/gitea-enhanced.ts(4 sites each, 2 files × 2 duplicated code blocks). The metadata mirror paths now run on every sync; the underlying mirror functions handle idempotency via their existing markers and dedup logic.Per-mirror deduplication is unchanged:
[GH-ISSUE #N]marker in Gitea issue title[GH-PR #N]marker in Gitea issue titleNote on labels: the labels mirror path still has its existing
!shouldMirrorIssuesThisRunguard, because the issue mirror creates labels inline as a side effect of creating each issue. CallingmirrorGitRepoLabelsToGiteaseparately would be redundant when issues are about to run. This is unchanged behavior.Testing
src/lib/gitea-enhanced.test.tshad a test that was actively enforcing the buggy behavior:Updated to reflect the corrected behavior:
Steps to Reproduce (pre-fix)
[Sync] Issues already mirrored ...; skippingin the logs.After the fix, the renamed title is PATCH'd to the existing Gitea issue (matched by
[GH-ISSUE #N]marker), no duplicates are created.Related
Possible follow-up (not in this PR)
This change reconciles metadata on every sync. For repos with many issues, that means a small bump in GitHub API usage per sync. A natural optimization is to pass
since=metadataState.components.issues.lastSyncedAtto the GitHub issues API so only issues updated since the last successful sync are fetched. That belongs in a separate PR; this one focuses on restoring correctness first.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.