[PR #362] [MERGED] feat: per-repository and per-organization mirror option overrides #8622

Closed
opened 2026-08-26 01:01:31 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/RayLabsHQ/gitea-mirror/pull/362
Author: @arunavo4
Created: 8/20/2026
Status: ✅ Merged
Merged: 8/20/2026
Merged by: @arunavo4

Base: main ← Head: feat/per-repo-mirror-overrides


📝 Commits (5)

  • 7624e89 feat: per-repository and per-organization mirror option overrides
  • 7a2d639 fix(ui): disable mirror toggles that cannot take effect, and explain why
  • fb6060d fix(ui): read inherited mirror flags from mirrorOptions, not giteaConfig
  • 9a43918 fix(ui): surface the mirror-options filter on desktop, and on organizations
  • 6021094 fix(ui): stop double-applying the mirrorMetadata switch when reading config

📊 Changes

19 files changed (+4291 additions, -102 deletions)

View changed files

➕ drizzle/0014_needy_white_tiger.sql (+2 -0)
➕ drizzle/meta/0014_snapshot.json (+2389 -0)
📝 drizzle/meta/_journal.json (+7 -0)
📝 scripts/validate-migrations.ts (+64 -0)
➕ src/components/config/MirrorOverridesDialog.tsx (+245 -0)
📝 src/components/organizations/Organization.tsx (+54 -1)
📝 src/components/organizations/OrganizationsList.tsx (+73 -11)
📝 src/components/repositories/Repository.tsx (+55 -1)
📝 src/components/repositories/RepositoryTable.tsx (+147 -5)
📝 src/hooks/useGiteaConfig.ts (+21 -1)
📝 src/lib/db/schema.ts (+32 -0)
📝 src/lib/gitea-enhanced.ts (+14 -13)
📝 src/lib/gitea.ts (+50 -49)
➕ src/lib/utils/mirror-overrides.test.ts (+610 -0)
➕ src/lib/utils/mirror-overrides.ts (+375 -0)
📝 src/pages/api/organizations/[id].ts (+51 -10)
➕ src/pages/api/organizations/mirror-overrides.ts (+47 -0)
📝 src/pages/api/repositories/[id].ts (+54 -11)
📝 src/types/filter.ts (+1 -0)

📄 Description

Closes #361.

Mirror options are global today, so a single repo that fails with LFS enabled can't be mirrored at all. The reporter's case: browser-use fails at the LFS stage every time, and the only workarounds are losing LFS everywhere or losing that repo.

We pass lfs: true straight into Gitea's /repos/migrate, so the LFS pull happens inside Gitea's own migration. When it fails, Gitea discards the whole migration and there's nothing left for us to salvage. That's why a per-repo opt-out is the fix rather than making the failure non-fatal.

What this adds

Per-repository and per-organization overrides for mirror options, resolved per flag: repository -> organization -> global -> false. null at a tier means inherit, so overriding LFS on one repo leaves its other flags alone.

Editing lives on the objects themselves, via the existing three-dot menus on the Repositories and Organizations pages. The Configuration page keeps the global defaults and gains no new surface. The repositories table gets a filter and a row badge so you can find which repos deviate.

Notable pieces

One resolver replaces scattered reads. resolveMirrorOptions() replaces 24 reads of config.giteaConfig?.* in gitea.ts, which were duplicated across two near-identical blocks, plus a third copy in gitea-enhanced.ts (syncGiteaRepoEnhanced). That third copy is the scheduled-sync path. Without it, overrides would have applied on the first mirror and been silently ignored on every sync afterwards.

Toggles that can't take effect are disabled and explained. starredCodeOnly forces metadata off for starred repos, and mirrorLabels is suppressed whenever issues run. Both used to be invisible. getMirrorOverrideGating() now disables those controls and shows the reason. STARRED_CLAMPED_KEYS is shared between that gating and the resolver's clamp, so the set the UI greys out can't drift from the set the runtime forces off.

Two pre-existing bugs fixed along the way. Both PATCH /api/repositories/[id] and PATCH /api/organizations/[id] unconditionally wrote destinationOrg: destinationOrg || null, so a request carrying only mirrorOverrides would have wiped the destination override. They're now real partial updates keyed on field presence, with Zod validation.

Notes

mirrorMetadata is deliberately not exposed. No mirror path reads it (grep returns 0 hits in both gitea.ts and gitea-enhanced.ts); it's a write-time master switch that config-mapper.ts ANDs into the individual flags at save time. A per-object override would store and resolve correctly and change nothing. Making it a real runtime gate is possible but would change behavior for anyone running MIRROR_METADATA=false with MIRROR_ISSUES=true, which works today.

Migration 0014 adds two nullable mirror_overrides text columns. Additive, existing rows read as inherit.

Testing

bun test 485 pass / 11 skip / 0 fail (up from 450 on main). bun run build succeeds. validate-migrations passes from scratch and on the upgrade path. No dependency changes, so bun.lock and bun.nix are untouched.


🔄 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/362 **Author:** [@arunavo4](https://github.com/arunavo4) **Created:** 8/20/2026 **Status:** ✅ Merged **Merged:** 8/20/2026 **Merged by:** [@arunavo4](https://github.com/arunavo4) **Base:** `main` ← **Head:** `feat/per-repo-mirror-overrides` --- ### 📝 Commits (5) - [`7624e89`](https://github.com/RayLabsHQ/gitea-mirror/commit/7624e89fe4efad6cb475a1f05fc764d62daecb98) feat: per-repository and per-organization mirror option overrides - [`7a2d639`](https://github.com/RayLabsHQ/gitea-mirror/commit/7a2d639d45f3a7a03b75b54a7fd9610b5c607844) fix(ui): disable mirror toggles that cannot take effect, and explain why - [`fb6060d`](https://github.com/RayLabsHQ/gitea-mirror/commit/fb6060d578a914687e7bf82b0eaf84711c58bb12) fix(ui): read inherited mirror flags from mirrorOptions, not giteaConfig - [`9a43918`](https://github.com/RayLabsHQ/gitea-mirror/commit/9a4391896356cf836400fe7240301b844ebe9c02) fix(ui): surface the mirror-options filter on desktop, and on organizations - [`6021094`](https://github.com/RayLabsHQ/gitea-mirror/commit/6021094543c3e2b560724591d9d217c258d3a5e4) fix(ui): stop double-applying the mirrorMetadata switch when reading config ### 📊 Changes **19 files changed** (+4291 additions, -102 deletions) <details> <summary>View changed files</summary> ➕ `drizzle/0014_needy_white_tiger.sql` (+2 -0) ➕ `drizzle/meta/0014_snapshot.json` (+2389 -0) 📝 `drizzle/meta/_journal.json` (+7 -0) 📝 `scripts/validate-migrations.ts` (+64 -0) ➕ `src/components/config/MirrorOverridesDialog.tsx` (+245 -0) 📝 `src/components/organizations/Organization.tsx` (+54 -1) 📝 `src/components/organizations/OrganizationsList.tsx` (+73 -11) 📝 `src/components/repositories/Repository.tsx` (+55 -1) 📝 `src/components/repositories/RepositoryTable.tsx` (+147 -5) 📝 `src/hooks/useGiteaConfig.ts` (+21 -1) 📝 `src/lib/db/schema.ts` (+32 -0) 📝 `src/lib/gitea-enhanced.ts` (+14 -13) 📝 `src/lib/gitea.ts` (+50 -49) ➕ `src/lib/utils/mirror-overrides.test.ts` (+610 -0) ➕ `src/lib/utils/mirror-overrides.ts` (+375 -0) 📝 `src/pages/api/organizations/[id].ts` (+51 -10) ➕ `src/pages/api/organizations/mirror-overrides.ts` (+47 -0) 📝 `src/pages/api/repositories/[id].ts` (+54 -11) 📝 `src/types/filter.ts` (+1 -0) </details> ### 📄 Description Closes #361. Mirror options are global today, so a single repo that fails with LFS enabled can't be mirrored at all. The reporter's case: `browser-use` fails at the LFS stage every time, and the only workarounds are losing LFS everywhere or losing that repo. We pass `lfs: true` straight into Gitea's `/repos/migrate`, so the LFS pull happens inside Gitea's own migration. When it fails, Gitea discards the whole migration and there's nothing left for us to salvage. That's why a per-repo opt-out is the fix rather than making the failure non-fatal. ## What this adds Per-repository and per-organization overrides for mirror options, resolved per flag: **repository -> organization -> global -> false**. `null` at a tier means inherit, so overriding LFS on one repo leaves its other flags alone. Editing lives on the objects themselves, via the existing three-dot menus on the Repositories and Organizations pages. The Configuration page keeps the global defaults and gains no new surface. The repositories table gets a filter and a row badge so you can find which repos deviate. ## Notable pieces **One resolver replaces scattered reads.** `resolveMirrorOptions()` replaces 24 reads of `config.giteaConfig?.*` in `gitea.ts`, which were duplicated across two near-identical blocks, plus a third copy in `gitea-enhanced.ts` (`syncGiteaRepoEnhanced`). That third copy is the scheduled-sync path. Without it, overrides would have applied on the first mirror and been silently ignored on every sync afterwards. **Toggles that can't take effect are disabled and explained.** `starredCodeOnly` forces metadata off for starred repos, and `mirrorLabels` is suppressed whenever issues run. Both used to be invisible. `getMirrorOverrideGating()` now disables those controls and shows the reason. `STARRED_CLAMPED_KEYS` is shared between that gating and the resolver's clamp, so the set the UI greys out can't drift from the set the runtime forces off. **Two pre-existing bugs fixed along the way.** Both `PATCH /api/repositories/[id]` and `PATCH /api/organizations/[id]` unconditionally wrote `destinationOrg: destinationOrg || null`, so a request carrying only `mirrorOverrides` would have wiped the destination override. They're now real partial updates keyed on field presence, with Zod validation. ## Notes `mirrorMetadata` is deliberately not exposed. No mirror path reads it (`grep` returns 0 hits in both `gitea.ts` and `gitea-enhanced.ts`); it's a write-time master switch that `config-mapper.ts` ANDs into the individual flags at save time. A per-object override would store and resolve correctly and change nothing. Making it a real runtime gate is possible but would change behavior for anyone running `MIRROR_METADATA=false` with `MIRROR_ISSUES=true`, which works today. Migration `0014` adds two nullable `mirror_overrides` text columns. Additive, existing rows read as inherit. ## Testing `bun test` 485 pass / 11 skip / 0 fail (up from 450 on main). `bun run build` succeeds. `validate-migrations` passes from scratch and on the upgrade path. No dependency changes, so `bun.lock` and `bun.nix` are untouched. --- <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-08-26 01:01:31 -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#8622