mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-11-16 14:45:02 -06:00
[PR #362] [MERGED] feat: per-repository and per-organization mirror option overrides #8969
Reference in New Issue
Block a user
📋 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)
7624e89feat: per-repository and per-organization mirror option overrides7a2d639fix(ui): disable mirror toggles that cannot take effect, and explain whyfb6060dfix(ui): read inherited mirror flags from mirrorOptions, not giteaConfig9a43918fix(ui): surface the mirror-options filter on desktop, and on organizations6021094fix(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-usefails at the LFS stage every time, and the only workarounds are losing LFS everywhere or losing that repo.We pass
lfs: truestraight 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.
nullat 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 ofconfig.giteaConfig?.*ingitea.ts, which were duplicated across two near-identical blocks, plus a third copy ingitea-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.
starredCodeOnlyforces metadata off for starred repos, andmirrorLabelsis suppressed whenever issues run. Both used to be invisible.getMirrorOverrideGating()now disables those controls and shows the reason.STARRED_CLAMPED_KEYSis 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]andPATCH /api/organizations/[id]unconditionally wrotedestinationOrg: destinationOrg || null, so a request carrying onlymirrorOverrideswould have wiped the destination override. They're now real partial updates keyed on field presence, with Zod validation.Notes
mirrorMetadatais deliberately not exposed. No mirror path reads it (grepreturns 0 hits in bothgitea.tsandgitea-enhanced.ts); it's a write-time master switch thatconfig-mapper.tsANDs 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 runningMIRROR_METADATA=falsewithMIRROR_ISSUES=true, which works today.Migration
0014adds two nullablemirror_overridestext columns. Additive, existing rows read as inherit.Testing
bun test485 pass / 11 skip / 0 fail (up from 450 on main).bun run buildsucceeds.validate-migrationspasses from scratch and on the upgrade path. No dependency changes, sobun.lockandbun.nixare untouched.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.