mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-08-29 20:11:46 +00:00
|
Some checks are pending
CI / test (push) Waiting to run
CI / windows (push) Waiting to run
CI / cross-compile (amd64, darwin) (push) Waiting to run
CI / cross-compile (amd64, windows) (push) Waiting to run
CI / cross-compile (arm64, darwin) (push) Waiting to run
CI / cross-compile (arm64, linux) (push) Waiting to run
CI / cross-compile (arm64, windows) (push) Waiting to run
CodeQL Advanced / Analyze (go) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Pages / build (push) Waiting to run
Deploy Pages / deploy (push) Blocked by required conditions
* feat(cli): add --output flag to write review/scan results to a file Add `--output <path>` / `-o` to `ocr review` and `ocr scan`, writing the result JSON or text directly to a UTF-8 file instead of stdout. The file is created lazily on the first write so a failed run never truncates an existing target; text-mode files are ANSI-stripped so terminal color codes never pollute the result file. A `[ocr] Results written to <path>` hint is printed to stderr once the file is actually created, and failure output keeps going to stderr so agents always find the failure reason. Closes #851 Signed-off-by: 历代星辰 * test(cli): cover --output flag parsing and file output behavior Add tests for --output/-o flag parsing, the stripAnsiWriter state machine (including escape sequences split across Write calls), lazy file creation (failed runs leave existing targets untouched, never-written targets are not created), and the Results-written stderr hint. Adapt existing emitRunResult / renderComment / outputPreview call sites to the new io.Writer parameter. Signed-off-by: 历代星辰 * fix(test): isolate USERPROFILE so Windows tests never touch the real OCR home os.UserHomeDir() prefers USERPROFILE over HOME on Windows, so t.Setenv("HOME", ...) alone left tests reading and writing the developer's real ~/.opencodereview: config tests overwrote config.json and session/agent tests polluted the sessions store. Add a setTestHome helper (per affected package) that also overrides USERPROFILE, and route every scattered HOME override through it. Signed-off-by: 历代星辰 * fix(cli): propagate output write failures and strip multi-byte ANSI escapes Address the ocr review findings on the --output feature: - lazyFileWriter now records the first write error (Err()) and emits the "Results written" hint only after a successful write; emitRunResult and outputPreview check it after text rendering, so a failed --output write (permission, disk full) exits non-zero like JSON mode already does instead of silently exiting 0 with no file. - stripAnsiWriter keeps multi-byte escapes (ESC + intermediate byte, DCS/PM/APC strings) inside the escape state so trailing bytes are discarded with the sequence instead of leaking into the result file. Signed-off-by: 历代星辰 * fix(cli): re-parse trailing byte after bare-ESC OSC termination and fix Write return semantics Addresses review comments on #852: - stripAnsiWriter ansiOSCEsc: a non-ST byte after ESC is no longer dropped. The OSC ends at a bare ESC terminator and the trailing byte is re-parsed — an ESC starts a new escape sequence, any other byte is forwarded as text. Previously the first byte after a bare-ESC-terminated OSC was silently lost. - stripAnsiWriter Write: report the underlying dst error but return len(p), since the state machine has already consumed the input; returning 0 made a caller retrying on n < len(p) feed the same bytes through twice. - Clarify --output help text: default is stdout and '-' also means stdout. Adds regression tests for both bugs (bare-ESC + trailing text, bare-ESC + new escape, and dst-failure return contract). Signed-off-by: 历代星辰 * fix(cli): reinforce ANSI stripper state machine and validate format flag * docs(cli): document output flag across localized references and READMEs * fix(cli): cap escape intermediate bytes and normalize format in output handlers --------- Signed-off-by: 历代星辰 |
||
|---|---|---|
| .. | ||
| comments.go | ||
| comments_test.go | ||
| final_manifest_test.go | ||
| history.go | ||
| history_test.go | ||
| list.go | ||
| list_error_test.go | ||
| list_more_test.go | ||
| list_test.go | ||
| manifest.go | ||
| manifest_guards_test.go | ||
| manifest_test.go | ||
| persist.go | ||
| persist_test.go | ||
| resume.go | ||
| resume_identity.go | ||
| resume_identity_test.go | ||
| resume_orphan_request_test.go | ||
| resume_test.go | ||
| test_home_test.go | ||
| testing.go | ||
| validate_scan_options_test.go | ||