Repository navigation
fix(cli): show --diff previews directory and symlink refusals (#1204) - #1206
Merged
Merged
Conversation
#1200 taught show --diff about the operator write-dir boundary. The other half of apply's destination refusals was still missing: a text artifact whose target is a directory or a symlink, and a tree whose root is a symlink, were advertised as written while the same apply exited 2. The two text-destination checks now live in one helper that both apply_payload and show_payload call, so the preview cannot drift. The tree branch of show calls _refuse_dest_link(dest, dest) before _write_to, the same refusal apply makes. show stays read-only: it reports apply's own message in apply_plan.error and does not raise. Closes #1204
Collaborator
Author
|
Review (Birfy) Tip SHA: f8d5a79
|
Birfy
enabled auto-merge (squash)
November 21, 2026 16:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1204.
Base: 2dff12b
Tip SHA: f8d5a79
What changed
#1200taughtshow --diffto preview the operator write-dir boundary.The other half of
apply's destination refusals was still missing, soshowadvertised writes thatapplyexits 2 on:spec.targetis a directory;spec.targetis a symlink;apply's text-destination checks (os.path.isdir(dest)and_refuse_dest_link(...)) now live in one helper,_refuse_text_dest,that both
apply_payloadand the text branch ofshow_payloadcall, sothe preview cannot drift. The tree branch of
showcalls_refuse_dest_link(dest, dest)before_write_to, the same refusalapplymakes (and that_write_towould not see, because itabspathsthe root).
apply's behaviour and its message bytes stay unchanged.showstays read-only: it reports the refusal inapply_plan.error,does not raise, and does not touch the destination.
docs/plugins.mdrecords the same destination refusals next to thewrite-dir paragraph from #1188.
Red first, at this PR's base (
2dff12b6) in a clean worktree with onlythe new test file present:
show --diff --jsonreturnedapply_planwithwrittenand noerrorfor a directory dest, a text symlink dest, and a tree symlink root. The
regular-file control already passed.
Ran at
f8d5a79fPYTHONPATH=. python -m pytest -o addopts="" -p no:cacheprovider -q tests/test_show_dest_refusals.py tests/test_write_dirs_apply_show.py tests/test_apply_symlink_dest.py tests/test_apply_noop.py tests/test_cli_apply_created_target.py tests/test_cli_apply_text_missing_parent.py tests/test_apply_backup_away_from_skills.py tests/test_apply_from.py tests/test_cli_write_error.py—56 passed;python -m tools.gen_api_docs --check—docs/api.md is up to date;python -m tools.changelog_fragments check—14 changelog fragment(s) OK.Not run
mkdocs build --strictin its exact form: this host is offline and thesocialplugin fetchesfonts.google.com. The diff adds two sentencesto
docs/plugins.md; CIdocsis the line.