Skip to content

Show diffs when sync overwrite replaces files #66

@coisa

Description

@coisa

Objective

Show a diff in sync summaries when overwrite would replace consumer files, instead of silently relying on backup files.

Current Limitation

When --overwrite replaces an existing consumer file, maintainers need to understand exactly what changed. Backup files can reduce data loss, but a clear diff in the sync summary is more useful for review and CI logs.

Proposed Work

Enhance overwrite reporting so dev-tools:sync displays a readable diff for overwritten files. Prefer using an existing PHP diff library already available through PHPUnit or its dependencies, when suitable, instead of implementing a custom diff engine.

Scope

  • Show before/after diffs for overwritten file resources.
  • Include the path being overwritten and the source resource.
  • Integrate with the final sync summary when available.
  • Keep output readable in terminal and CI logs.
  • Avoid writing backup files as the primary strategy unless a separate explicit option is introduced later.

Non-goals

  • Creating backup files by default.
  • Implementing an interactive prompt.
  • Showing diffs for binary files in the first implementation.

Acceptance Criteria

Functional Criteria

  • dev-tools:sync --overwrite reports a diff for each text file it replaces.
  • The diff appears in the sync output or final summary with the affected path.
  • Unchanged overwritten targets are reported as no-op or unchanged.
  • Binary or unreadable files are handled gracefully with a clear message.
  • Tests cover changed text files, unchanged files, and non-text/binary fallback behavior.

Architectural / Isolation Criteria

  • Diff rendering is isolated behind a small service/helper.
  • The implementation reuses a maintained diff component when practical.
  • Output is deterministic enough for assertions.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Released

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions