[PR #370] [MERGED] feat(mirror): per-repo release limit, description sync on every sync, tidier mobile cards #8629

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

📋 Pull Request Information

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

Base: main ← Head: feat/361-followups


📝 Commits (1)

  • c1282d7 feat(mirror): per-repo release limit, description sync on every sync, tidier mobile cards

📊 Changes

9 files changed (+1094 additions, -143 deletions)

View changed files

📝 src/components/config/MirrorOverridesDialog.tsx (+144 -42)
📝 src/components/repositories/RepositoryTable.tsx (+57 -41)
📝 src/lib/db/schema.ts (+10 -2)
📝 src/lib/gitea-enhanced.test.ts (+78 -0)
📝 src/lib/gitea-enhanced.ts (+33 -0)
➕ src/lib/gitea-repo-metadata.test.ts (+335 -0)
📝 src/lib/gitea.ts (+136 -38)
📝 src/lib/utils/mirror-overrides.test.ts (+205 -2)
📝 src/lib/utils/mirror-overrides.ts (+96 -18)

📄 Description

Follow-up to #362 and #365, covering the three points @MMMMMoris raised in https://github.com/RayLabsHQ/gitea-mirror/issues/361#issuecomment-5377981716.

1. Releases and tags

To answer the question first: tags are not something we mirror ourselves. Gitea's own git mirror fetches every ref from upstream, tags included, so they arrive with the code on every pull and there is no per-repo control over them. They also cost nothing extra to store, a tag is a pointer to a commit that is already in the clone. Releases are different. We create them through the Gitea API on top of tags that already exist in the mirror, and the release assets are where the disk usage comes from. There is already a global "latest N releases" setting (default 10), and the release mirror prunes anything in Gitea beyond it.

So a "max tags" option does not apply, but a per-repo and per-org release limit does. This PR adds it:

  • releaseLimit joins mirrorOverrides on repositories and organizations, with the same precedence as the flags: repo, then org, then global, then the default of 10. It is the one non-boolean override, so it sits next to MIRROR_OVERRIDE_KEYS rather than inside it, and the resolver returns it as a definite positive integer.
  • An unusable value (0, negative, NaN) at one tier falls through to the next instead of being clamped to 1. The schema deliberately accepts any number so a bad stored limit degrades to "inherit" for that field alone, rather than making the whole overrides object unparseable and silently dropping the LFS opt-out stored next to it.
  • The Mirror Options dialog gets a "Release limit" field directly under Releases, with the inherited value as the hint. It is disabled with a reason while releases resolve to off, Save is blocked on invalid input, and empty means inherit.
  • mirrorGitHubReleasesToGitea takes the resolved limit from its three callers and resolves it itself when a caller does not pass one, so direct callers honor the overrides too.

2. Repository description

The description was already being sent to Gitea at migration time (#224), but only from the value stored in our own database, and only once. Two ways to end up with a blank description in Gitea: the repository was imported before #224 shipped (the bulk import only inserts new rows and never refreshes existing ones, so those rows have no description to send), or the upstream description changed after the mirror was created. Neither case ever recovered, because the sync path did not touch the description at all.

Now syncRepositoryMetadataToGitea runs on every sync as well as after migration, and reads the description and topics straight from GitHub. GET /repos/{owner}/{repo} carries both, so it replaces the topics-only call rather than adding one. GitHub is authoritative when reachable. The stored value is only a fallback for the no-token and GitHub-down cases, and an empty fallback is never written, so an outage cannot wipe a description Gitea already has. The refreshed description is written back to our row as well. Writes are skipped when Gitea already holds the same values, using the repo info the sync path fetches anyway, and the GitHub client's ETag layer turns the per-sync re-check into a 304 that does not count against the rate limit when nothing changed.

Existing mirrors pick the description up on their next sync, no re-mirror needed.

One behaviour change to be aware of: the sync path used to never touch the description, now it keeps it equal to GitHub's. If someone edited a mirror's description by hand in Gitea, the next sync puts the GitHub one back. That is the mirror semantics topics already follow.

3. Mobile repository card

Layout reworked along the lines of the mock-ups in the comment:

  • Name, Custom badge and the menu share one vertically centred row, so the name sits at the same height whether or not the badge is present. That was the misalignment in the last screenshot: the checkbox, the name and the menu button each had a different centre line.
  • Private, Fork and Starred move to their own row under the name, indented to it.
  • Owner, Org and Dest stay on the left; status and last-sync time stack on the right.

Mobile repository cards with the reworked layout Mirror options dialog on mobile with the new Release limit field

Same field in the organization dialog on desktop:

Organization mirror options dialog on desktop

Verification

  • bun test: 533 pass, 0 fail. 30 new tests: resolver precedence and helpers for the limit, the release-limit gating, syncRepositoryMetadataToGitea in isolation (GitHub wins, fallback paths, skip-when-unchanged, outage never wipes, prefix handling), and the sync path both calling the metadata sync and passing the resolved limit through.
  • bunx --bun astro build clean.
  • Browser at 390px and 1400px against a seeded database: card layout, dialog save persists {"lfs":false,"releaseLimit":5}, releases-off disables the limit with a reason, 0 blocks Save, and an org-level limit shows up as the repository's inherited hint.

🔄 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/370 **Author:** [@arunavo4](https://github.com/arunavo4) **Created:** 8/24/2026 **Status:** ✅ Merged **Merged:** 8/24/2026 **Merged by:** [@arunavo4](https://github.com/arunavo4) **Base:** `main` ← **Head:** `feat/361-followups` --- ### 📝 Commits (1) - [`c1282d7`](https://github.com/RayLabsHQ/gitea-mirror/commit/c1282d777c19b422f87d409fcdb117a7651fc0c9) feat(mirror): per-repo release limit, description sync on every sync, tidier mobile cards ### 📊 Changes **9 files changed** (+1094 additions, -143 deletions) <details> <summary>View changed files</summary> 📝 `src/components/config/MirrorOverridesDialog.tsx` (+144 -42) 📝 `src/components/repositories/RepositoryTable.tsx` (+57 -41) 📝 `src/lib/db/schema.ts` (+10 -2) 📝 `src/lib/gitea-enhanced.test.ts` (+78 -0) 📝 `src/lib/gitea-enhanced.ts` (+33 -0) ➕ `src/lib/gitea-repo-metadata.test.ts` (+335 -0) 📝 `src/lib/gitea.ts` (+136 -38) 📝 `src/lib/utils/mirror-overrides.test.ts` (+205 -2) 📝 `src/lib/utils/mirror-overrides.ts` (+96 -18) </details> ### 📄 Description Follow-up to #362 and #365, covering the three points @MMMMMoris raised in https://github.com/RayLabsHQ/gitea-mirror/issues/361#issuecomment-5377981716. ## 1. Releases and tags To answer the question first: tags are not something we mirror ourselves. Gitea's own git mirror fetches every ref from upstream, tags included, so they arrive with the code on every pull and there is no per-repo control over them. They also cost nothing extra to store, a tag is a pointer to a commit that is already in the clone. Releases are different. We create them through the Gitea API on top of tags that already exist in the mirror, and the release assets are where the disk usage comes from. There is already a global "latest N releases" setting (default 10), and the release mirror prunes anything in Gitea beyond it. So a "max tags" option does not apply, but a per-repo and per-org release limit does. This PR adds it: - `releaseLimit` joins `mirrorOverrides` on repositories and organizations, with the same precedence as the flags: repo, then org, then global, then the default of 10. It is the one non-boolean override, so it sits next to `MIRROR_OVERRIDE_KEYS` rather than inside it, and the resolver returns it as a definite positive integer. - An unusable value (0, negative, NaN) at one tier falls through to the next instead of being clamped to 1. The schema deliberately accepts any number so a bad stored limit degrades to "inherit" for that field alone, rather than making the whole overrides object unparseable and silently dropping the LFS opt-out stored next to it. - The Mirror Options dialog gets a "Release limit" field directly under Releases, with the inherited value as the hint. It is disabled with a reason while releases resolve to off, Save is blocked on invalid input, and empty means inherit. - `mirrorGitHubReleasesToGitea` takes the resolved limit from its three callers and resolves it itself when a caller does not pass one, so direct callers honor the overrides too. ## 2. Repository description The description was already being sent to Gitea at migration time (#224), but only from the value stored in our own database, and only once. Two ways to end up with a blank description in Gitea: the repository was imported before #224 shipped (the bulk import only inserts new rows and never refreshes existing ones, so those rows have no description to send), or the upstream description changed after the mirror was created. Neither case ever recovered, because the sync path did not touch the description at all. Now `syncRepositoryMetadataToGitea` runs on every sync as well as after migration, and reads the description and topics straight from GitHub. `GET /repos/{owner}/{repo}` carries both, so it replaces the topics-only call rather than adding one. GitHub is authoritative when reachable. The stored value is only a fallback for the no-token and GitHub-down cases, and an empty fallback is never written, so an outage cannot wipe a description Gitea already has. The refreshed description is written back to our row as well. Writes are skipped when Gitea already holds the same values, using the repo info the sync path fetches anyway, and the GitHub client's ETag layer turns the per-sync re-check into a 304 that does not count against the rate limit when nothing changed. Existing mirrors pick the description up on their next sync, no re-mirror needed. One behaviour change to be aware of: the sync path used to never touch the description, now it keeps it equal to GitHub's. If someone edited a mirror's description by hand in Gitea, the next sync puts the GitHub one back. That is the mirror semantics topics already follow. ## 3. Mobile repository card Layout reworked along the lines of the mock-ups in the comment: - Name, `Custom` badge and the menu share one vertically centred row, so the name sits at the same height whether or not the badge is present. That was the misalignment in the last screenshot: the checkbox, the name and the menu button each had a different centre line. - Private, Fork and Starred move to their own row under the name, indented to it. - Owner, Org and Dest stay on the left; status and last-sync time stack on the right. <img src="https://gist.githubusercontent.com/arunavo4/d044dc02b7cce2d565e8aa1efb032c8e/raw/cf4bcb494f28a0482b696cad399893cf6a74ae9b/mobile-cards.png" width="320" alt="Mobile repository cards with the reworked layout" /> <img src="https://gist.githubusercontent.com/arunavo4/d044dc02b7cce2d565e8aa1efb032c8e/raw/cf4bcb494f28a0482b696cad399893cf6a74ae9b/mobile-dialog.png" width="320" alt="Mirror options dialog on mobile with the new Release limit field" /> Same field in the organization dialog on desktop: <img src="https://gist.githubusercontent.com/arunavo4/d044dc02b7cce2d565e8aa1efb032c8e/raw/cf4bcb494f28a0482b696cad399893cf6a74ae9b/desktop-org-dialog.png" width="640" alt="Organization mirror options dialog on desktop" /> ## Verification - `bun test`: 533 pass, 0 fail. 30 new tests: resolver precedence and helpers for the limit, the release-limit gating, `syncRepositoryMetadataToGitea` in isolation (GitHub wins, fallback paths, skip-when-unchanged, outage never wipes, prefix handling), and the sync path both calling the metadata sync and passing the resolved limit through. - `bunx --bun astro build` clean. - Browser at 390px and 1400px against a seeded database: card layout, dialog save persists `{"lfs":false,"releaseLimit":5}`, releases-off disables the limit with a reason, `0` blocks Save, and an org-level limit shows up as the repository's inherited hint. --- <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:04:25 -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#8629