Skip to content

Add restore dry-run preview#78

Draft
olxgdm wants to merge 6 commits into
mainfrom
77-add-restore-dry-run-preview
Draft

Add restore dry-run preview#78
olxgdm wants to merge 6 commits into
mainfrom
77-add-restore-dry-run-preview

Conversation

@olxgdm

@olxgdm olxgdm commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #77.

This PR adds a non-mutating restore preview mode for both single-file and batch restore flows:

  • cfgsync restore <file> --dry-run
  • cfgsync restore --all --dry-run
  • prefix-remapped dry-runs with --from-prefix / --to-prefix

Dry-run validates the same restore inputs that apply mode depends on, including tracked registry entries, stored backup paths, ordinary-file backups, prefix remapping, and destination state. It then prints one impact line per planned restore without copying files, creating destination parent directories, or mutating registry/storage/app config/original files.

Behavior

Dry-run emits machine-readable preview lines:

would-create <destination>
would-overwrite <destination>
unchanged <destination>

The command class now uses an explicit RestoreMode { Apply, DryRun }, keeping real file copying in StorageManager::RestoreEntry and keeping dry-run planning in RestoreCommand.

Batch dry-run preserves existing restore batch semantics: recoverable per-file failures are reported, later registry entries continue to be processed, and the command exits non-zero with the existing Restore completed with N failure(s). summary.

Implementation Notes

  • Adds --dry-run to the restore CLI.
  • Reuses existing restore prefix-remap behavior.
  • Validates stored backups through StorageManager::ResolveStoredPath and ordinary-file checks.
  • Compares stored and destination files byte-for-byte to distinguish unchanged from would-overwrite.
  • Treats existing non-ordinary destinations as invalid destination state.
  • Updates README restore and fresh-system examples to show preview-before-apply workflows.

Tests

Added command-level and CLI-level coverage for:

  • single-file dry-run preserving changed destination contents
  • batch dry-run preserving multiple destinations
  • would-create, would-overwrite, and unchanged output
  • prefix-remapped dry-run without destination directory creation
  • missing stored backup failures
  • batch dry-run continuation after an outside-prefix failure
  • restore --help documenting --dry-run

Verification

Ran locally:

cmake --build build
ctest --test-dir build -R "RestoreCommand|RestoreCommandCli" --output-on-failure
ctest --test-dir build --output-on-failure
ctest --test-dir build --output-on-failure --quiet

All tests passed, including the full CTest suite: 260/260.

@olxgdm olxgdm linked an issue Jun 26, 2026 that may be closed by this pull request
@olxgdm olxgdm changed the title [codex] Add restore dry-run preview Add restore dry-run preview Jun 26, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
71.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add restore dry-run preview

1 participant