Repository navigation
feat(review): default --to to HEAD when only --from is given - #1936
Conversation
Reviewing the current branch against a known base is a common workflow, but it previously required spelling out --to HEAD. Normalize a missing target to HEAD inside review-option validation so the shorthand takes the exact same merge-base range path, while plain review keeps workspace mode and delegate keeps requiring --to. Add a Git-backed preview test on diverged branches, and document the conditional default in all five cli-reference locales. Fixes alibaba#1935
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
|
| func addDiffFlags(cmd *cobra.Command, from, to, commit *string) { | ||
| cmd.Flags().StringVar(from, "from", "", "source ref to start diff from (e.g., 'main')") | ||
| cmd.Flags().StringVar(to, "to", "", "target ref to end diff at (e.g., 'feature-branch')") | ||
| cmd.Flags().StringVar(to, "to", "", "target ref to end diff at (e.g., 'feature-branch'; defaults to HEAD when --from is given)") |
There was a problem hiding this comment.
The updated help text for --to states "defaults to HEAD when --from is given", but addDiffFlags is shared between both review and delegate commands. The HEAD-defaulting behavior only applies to ocr review (via validateReviewOptions); ocr delegate still requires --to explicitly and will error out without it. This help text will mislead delegate users.
Consider either: (1) keeping the generic help text here and documenting the shorthand only in the review command's example/long description (which already does this), or (2) splitting the flag registration so each command gets its own accurate help string.
|
@Walternater Thanks for implementing this. I would prefer to make the shorthand consistent across normal review and delegation in this PR, and update the repository-provided skills together. I realize #1935 explicitly scoped the change to
This would give users and host agents one consistent convention across both modes, with implementation, documentation, and skills aligned. |
lizhengfeng101
left a comment
There was a problem hiding this comment.
Reviewed the original change and the maintainer follow-up at 99b958c. Conditional target normalization is consistent across review and both delegate subcommands, with workspace mode and conflict validation preserved. Local checks, race-enabled tests, build, and 91.7% coverage passed; OCR reported no findings in the follow-up production changes. The corresponding skills and localized documentation are synchronized. Waiting for the updated CI checks before merging.
|
I saw you pushed
One small observation for machine-readable symmetry: AI-assisted: implemented/verified with DeepSeek Harness (deepseek-v4.1-flash); commands and results above were run locally. |
Summary
Default a missing
--totoHEADwhen--fromis supplied in all three commands:ocr review --from mainocr delegate preview --from mainocr delegate rule --from main <path...>Each shorthand behaves like its explicit
--to HEADform. Range review keeps the existingmerge-base(from, HEAD)..HEADsemantics: committed changes only, excluding staged, unstaged, and untracked changes.At the maintainer's request, this expands the original review-only scope of #1935 to make normal review and delegation consistent. Plain commands remain in workspace mode; explicit targets take precedence; missing-base and conflicting range/commit flags still fail.
Changes
Maintainer Verification
make check— passed.make test— passed, including race detection.make coverage— 91.7% (90% threshold).make buildandgit diff --check— passed.Local verification uses project-local
dist/tmpforTMPDIRandGOTMPDIR, withGIT_CEILING_DIRECTORIESset to the same directory so non-repository fixtures do not inherit the containing checkout.Fixes #1935
AI Disclosure
Original author disclosure: Implemented with DeepSeek Harness (
deepseek-v4.1-flash); the author reviewed the diff and ran the original checks.The maintainer follow-up was prepared using OpenAI Codex and checked with
ocr; the Codex session's model identifier was not exposed. The maintainer requested and authorized the scope expansion and update. No AI attribution trailers are included in the commits.