Add copy-pasteable shell line to review-log header#88
Merged
Conversation
Add _shell_repro_line helper function that constructs a reproducible POSIX shell command from cwd, environment variables, and argv. Modify _invoke_script to compute and log this line alongside the existing header, with DRAFT_* env vars sorted alphabetically. Add unit tests for the helper and integration test verifying the log output.
- Replace shlex.split round-trip with real bash -c subprocess execution — missing shell round-trip test — shlex.split does not exercise shell expansion/assignment semantics; actual bash execution catches quoting regressions the weaker parser check would miss - Assert exact ordered header lines by index instead of broad any() membership checks — integration test under-checks header wiring — spec requires the shell repro line immediately follows DRAFT env: in a single write; positional assertions guard that ordering guarantee
…env mismatch
- Remove `tmp_path` fixture and subprocess round-trip from
`test_env_value_special_chars_quoted`; assert directly on
`shlex.quote` output — spec Step 3 forbids fixtures/mocks in
unit tests
- Switch integration test `test_invoke_script_writes_shell_repro_line`
to `env={}` and update regex/assertion to match empty-env form —
spec Step 4 requires an empty env and the `^\$ cd .+ && /bin/true$`
pattern
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.
Summary
Adds a
_shell_repro_linehelper function that constructs a reproducible POSIX shell command from cwd, environment variables, and argv. Modified_invoke_scriptto compute and log this line as a trailing line in the review-log header, allowing users to copy-paste the command to reproduce a review run without manual quoting or env var stitching.The shell line format is
$ cd <cwd> && [DRAFT_X=v ...] argv, where DRAFT_* env vars are sorted alphabetically for determinism and diff-friendliness, and all shell-special characters are properly quoted withshlex.quoteandshlex.join. The existing four-line header (=== review @,argv:,CWD:,DRAFT env:) remains unchanged, and the new line is appended in a single atomic write.Test plan
_shell_repro_linecover: empty env, env vars with spaces, special characters, cwd with spaces, argv with spaces, and determinism across multiple calls_invoke_scriptwrites the shell line correctly to the log file, with proper ordering after the DRAFT env line