[PR #190] [MERGED] Add pre-sync snapshot protection for mirror rewrites #177

Closed
opened 2026-02-27 15:55:26 +03:00 by kerem · 0 comments
Owner

📋 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: mainHead: codex/pre-sync-backup-guard


📝 Commits (4)

  • 043c1cf add pre-sync snapshot protection
  • 76d12c4 stabilize test module mocks
  • 91e6efb fix cross-test gitea mock exports
  • 2e29f6c fix 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

  • 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

🔄 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>
kerem 2026-02-27 15:55:26 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gitea-mirror#177
No description provided.