Repository navigation
Description
Description
Reviewing the current branch against a known base is a common workflow, but the CLI currently requires users to spell out --to HEAD:
ocr review --from main
# Error: --to is required when --from is specifiedSupport --from <ref> without --to as shorthand for targeting HEAD:
ocr review --from main
# Equivalent to:
ocr review --from main --to HEADThis must retain the existing range semantics: compare merge-base(main, HEAD) with HEAD, as in git diff main...HEAD. It reviews committed changes, not staged, unstaged, or untracked working-tree changes.
Scope
cmd/opencodereview/shared_flags.go: normalize the missing target toHEADin review-option handling before downstream validation and execution; update flag help. Do not set an unconditional flag default, which would change plainocr review.cmd/opencodereview/review_cmd.go: update command examples and ensure the shorthand uses the same range-review path as explicit--to HEAD.cmd/opencodereview/flags_test.goandcmd/opencodereview/review_cmd_test.go: replace tests expecting a missing-target error and add regression coverage.pages/src/content/docs/en/cli-reference.md: document the conditional default and its committed-changes-only scope. Keep affected localized documentation in sync; if README examples are updated, sync all localized READMEs as required by the repository.- Limit the behavior change to
ocr review. Shared flag/validation helpers also serveocr delegate; preserve that command's existing behavior. No changes to merge-base calculation, automatic fetching, or base-branch inference are needed.
Acceptance Criteria
-
ocr review --from mainresolves its target toHEADand behaves identically toocr review --from main --to HEAD. - Plain
ocr reviewremains workspace mode, including staged, unstaged, and untracked changes.--tois not globally defaulted toHEAD. - An explicit
--to <ref>remains authoritative. Supplying--towithout--fromstill fails with the existing missing-base error; the CLI does not guess a base branch. -
--from main --commit <sha>still fails as conflicting review modes, and existing ref-validation safeguards remain intact. - A Git-backed preview test verifies shorthand/explicit equivalence on diverged branches: main-only commits and uncommitted changes are not included in the reviewed diff. No LLM request is needed for this test.
- Preview and existing review metadata/reporting consistently reflect the effective target and resolved range, just as with explicit
--to HEAD. - Help and documentation explain the shorthand, merge-base semantics, and the distinction from workspace review.
- Tests cover the new default and unchanged modes, including the shared-helper boundary with
ocr delegate. - Relevant tests and project checks pass using
make test,make check, andmake coverage(90% threshold).
Context
This arose while explaining how to review the current branch relative to main. The current rejection is explicit in validateDiffMode and covered by TestParseReviewFlags_FromWithoutTo and TestParseReviewFlagsRejectsFromWithoutTo. The existing diff provider already supports the desired behavior when --to HEAD is supplied; this is a CLI usability improvement, not a new diff mode.
AI/LLM disclosure: This issue was drafted with OpenAI Codex using the gpt-6-astra model.
Activity
Walternater commentedon Nov 14, 2026
I'd like to take this one.
Plan: normalize a missing
--totoHEADonly in the review-option handling (validateReviewOptions), soocr review --from maintakes exactly the same range-review path as--to HEAD, while plainocr reviewanddelegatekeep their current behavior. I'll update the flag help/examples, replace the two rejection tests, add a Git-backed preview test on diverged branches (shorthand ≡ explicit; main-only commits and uncommitted changes excluded), and sync the fivecli-reference.mdlocales. PR to follow.AI-assisted: implemented with DeepSeek Harness (
deepseek-v4.1-flash); the PR will carry the same disclosure.Walternater commentedon Nov 14, 2026
PR opened: #1936 — normalize missing
--totoHEADin review-option validation only, plus a Git-backed preview e2e and 5-locale cli-reference sync.