diff --git a/docs/FORCE_PUSH_PROTECTION.md b/docs/FORCE_PUSH_PROTECTION.md index f15b1d2..b1e75d5 100644 --- a/docs/FORCE_PUSH_PROTECTION.md +++ b/docs/FORCE_PUSH_PROTECTION.md @@ -78,7 +78,11 @@ These appear when any non-disabled strategy is selected: ### Snapshot Retention Count -How many backup snapshots to keep per repository. Oldest snapshots are deleted when this limit is exceeded. Default: **20**. +How many backup snapshots to keep per repository. Oldest snapshots are deleted when this limit is exceeded. Default: **5**. + +### Snapshot Retention Days + +Maximum age (in days) for backup snapshots. Bundles older than this are deleted during retention enforcement, though at least one bundle is always kept. Set to `0` to disable time-based retention. Default: **30**. ### Snapshot Directory @@ -96,7 +100,7 @@ The old `backupBeforeSync` boolean is still recognized: | Old Setting | New Equivalent | |---|---| -| `backupBeforeSync: true` | `backupStrategy: "always"` | +| `backupBeforeSync: true` | `backupStrategy: "on-force-push"` | | `backupBeforeSync: false` | `backupStrategy: "disabled"` | | Neither set | `backupStrategy: "on-force-push"` (new default) | diff --git a/src/components/config/ConfigTabs.tsx b/src/components/config/ConfigTabs.tsx index 5fb7af9..9eb9877 100644 --- a/src/components/config/ConfigTabs.tsx +++ b/src/components/config/ConfigTabs.tsx @@ -51,7 +51,8 @@ export function ConfigTabs() { starredReposMode: 'dedicated-org', preserveOrgStructure: false, backupStrategy: "on-force-push", - backupRetentionCount: 20, + backupRetentionCount: 5, + backupRetentionDays: 30, backupDirectory: 'data/repo-backups', blockSyncOnBackupFailure: true, }, diff --git a/src/components/config/GitHubConfigForm.tsx b/src/components/config/GitHubConfigForm.tsx index c0cb441..d24bc4f 100644 --- a/src/components/config/GitHubConfigForm.tsx +++ b/src/components/config/GitHubConfigForm.tsx @@ -234,7 +234,7 @@ export function GitHubConfigForm({ { value: "always", label: "Always Backup", - desc: "Snapshot before every sync", + desc: "Snapshot before every sync (high disk usage)", }, { value: "on-force-push", @@ -272,7 +272,7 @@ export function GitHubConfigForm({ {(giteaConfig.backupStrategy ?? "on-force-push") !== "disabled" && ( <> -
+
+
+ + { + const newConfig = { + ...giteaConfig, + backupRetentionDays: Math.max(0, Number.parseInt(e.target.value, 10) || 0), + }; + setGiteaConfig(newConfig); + if (onGiteaAutoSave) onGiteaAutoSave(newConfig); + }} + className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring" + /> +

0 = no time-based limit

+