integrate snapshot creation into sync flow with configurable fail-closed/fail-open behavior
add tests for snapshot failure handling modes
Why
Mirror sync currently follows upstream history rewrites (including destructive force-pushes). This adds restore points so users can recover prior state.
Testing
bun test
bun run build
🔄 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/190
**Author:** [@arunavo4](https://github.com/arunavo4)
**Created:** 2/26/2026
**Status:** ✅ Merged
**Merged:** 2/26/2026
**Merged by:** [@arunavo4](https://github.com/arunavo4)
**Base:** `main` ← **Head:** `codex/pre-sync-backup-guard`
---
### 📝 Commits (4)
- [`043c1cf`](https://github.com/RayLabsHQ/gitea-mirror/commit/043c1cf4c5eb9b269b0f2911535f79d0ff532b12) add pre-sync snapshot protection
- [`76d12c4`](https://github.com/RayLabsHQ/gitea-mirror/commit/76d12c41e69f6b3dd65e95709d6eea3165538e79) stabilize test module mocks
- [`91e6efb`](https://github.com/RayLabsHQ/gitea-mirror/commit/91e6efb7d93a816b59416af482619ededd3d4e5d) fix cross-test gitea mock exports
- [`2e29f6c`](https://github.com/RayLabsHQ/gitea-mirror/commit/2e29f6c3df94beffa1da0b29508a895da297f9de) fix gitea mock strategy behavior
### 📊 Changes
**12 files changed** (+546 additions, -8 deletions)
<details>
<summary>View changed files</summary>
📝 `src/components/config/ConfigTabs.tsx` (+4 -0)
📝 `src/components/config/GiteaConfigForm.tsx` (+79 -2)
📝 `src/lib/db/schema.ts` (+4 -0)
📝 `src/lib/gitea-enhanced.test.ts` (+146 -1)
📝 `src/lib/gitea-enhanced.ts` (+60 -0)
📝 `src/lib/gitea-starred-repos.test.ts` (+13 -2)
📝 `src/lib/gitea.test.ts` (+49 -1)
➕ `src/lib/repo-backup.ts` (+164 -0)
📝 `src/lib/utils/config-defaults.ts` (+4 -0)
📝 `src/lib/utils/config-mapper.ts` (+8 -0)
📝 `src/pages/api/job/mirror-repo.test.ts` (+11 -2)
📝 `src/types/config.ts` (+4 -0)
</details>
### 📄 Description
## Summary
- add pre-sync repository bundle snapshots before mirror sync
- add backup protection settings to Gitea config (enable toggle, retention count, backup directory, block-on-failure)
- integrate snapshot creation into sync flow with configurable fail-closed/fail-open behavior
- add tests for snapshot failure handling modes
## Why
Mirror sync currently follows upstream history rewrites (including destructive force-pushes). This adds restore points so users can recover prior state.
## Testing
- bun test
- bun run build
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/RayLabsHQ/gitea-mirror/pull/190
Author: @arunavo4
Created: 2/26/2026
Status: ✅ Merged
Merged: 2/26/2026
Merged by: @arunavo4
Base:
main← Head:codex/pre-sync-backup-guard📝 Commits (4)
043c1cfadd pre-sync snapshot protection76d12c4stabilize test module mocks91e6efbfix cross-test gitea mock exports2e29f6cfix gitea mock strategy behavior📊 Changes
12 files changed (+546 additions, -8 deletions)
View changed files
📝
src/components/config/ConfigTabs.tsx(+4 -0)📝
src/components/config/GiteaConfigForm.tsx(+79 -2)📝
src/lib/db/schema.ts(+4 -0)📝
src/lib/gitea-enhanced.test.ts(+146 -1)📝
src/lib/gitea-enhanced.ts(+60 -0)📝
src/lib/gitea-starred-repos.test.ts(+13 -2)📝
src/lib/gitea.test.ts(+49 -1)➕
src/lib/repo-backup.ts(+164 -0)📝
src/lib/utils/config-defaults.ts(+4 -0)📝
src/lib/utils/config-mapper.ts(+8 -0)📝
src/pages/api/job/mirror-repo.test.ts(+11 -2)📝
src/types/config.ts(+4 -0)📄 Description
Summary
Why
Mirror sync currently follows upstream history rewrites (including destructive force-pushes). This adds restore points so users can recover prior state.
Testing
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.