review-state: --git-sha is documented on 'write' and silently ignored there #495

Closed
opened 2026-09-01 15:32:39 +00:00 by mph · 1 comment
Owner

Found triaging IW-436 (LESSONS.md entry 6).

docs/commands/review-state.md:104 lists --git-sha <value> in the write flag table (Override auto-detected git SHA), and :153 extends that same table to update ("All flags from write command, plus:").

But parseWriteArgs's yield sets gitSha = defaults.gitSha (core/model/ReviewStateCliParser.scala:182), and defaults is built entirely from WriteDefaults in core/commands/ReviewState.scala:132-136, whose gitSha comes from env.git.getHeadSha(env.cwd).toOption (:135). The flag list passed to parseWriteArgs is never consulted for --git-sha. Only parseUpdateArgs:229 reads the flag.

Observed

./iw review-state write --git-sha 1234567 ...

writes the actual HEAD SHA, not 1234567, with no warning and exit 0. The documented override does nothing on write; it works only on update.

Wanted

Either honour --git-sha in parseWriteArgs, or drop the row from the write flag table.

Scope note

This is the opposite shape to IW-436 defect 5 (which was update failing to refresh git_sha when no flag is given); this is a flag given and dropped. IW-436 RESOLVED 3 confined that phase to applyUpdate, so this code was left as it is.

Found triaging IW-436 (LESSONS.md entry 6). `docs/commands/review-state.md:104` lists `--git-sha <value>` in the `write` flag table (`Override auto-detected git SHA`), and `:153` extends that same table to `update` ("All flags from `write` command, plus:"). But `parseWriteArgs`'s `yield` sets `gitSha = defaults.gitSha` (`core/model/ReviewStateCliParser.scala:182`), and `defaults` is built entirely from `WriteDefaults` in `core/commands/ReviewState.scala:132-136`, whose `gitSha` comes from `env.git.getHeadSha(env.cwd).toOption` (`:135`). The flag list passed to `parseWriteArgs` is never consulted for `--git-sha`. Only `parseUpdateArgs:229` reads the flag. ## Observed ``` ./iw review-state write --git-sha 1234567 ... ``` writes the actual HEAD SHA, not `1234567`, with no warning and exit 0. The documented override does nothing on `write`; it works only on `update`. ## Wanted Either honour `--git-sha` in `parseWriteArgs`, or drop the row from the `write` flag table. ## Scope note This is the opposite shape to IW-436 defect 5 (which was `update` failing to refresh `git_sha` when **no** flag is given); this is a flag given and dropped. IW-436 RESOLVED 3 confined that phase to `applyUpdate`, so this code was left as it is.
Member

Intake: fixed by 8cea0acb

8cea0acb ("Generated docs and skill") generates docs/commands/review-state.md from the declaration registry. Its diff removes the --git-sha row from the write flag table and the line "All flags from write command, plus:". This is the second option in "Wanted": drop the row from the write table. Now only update lists --git-sha (docs/commands/review-state.md:23), and update honours it.

Also, 7f1a97fe (#500) makes write refuse flags that it does not declare. On origin/main, ./iw review-state write --git-sha 1234567 ... now stops with Error: Unknown flag: --git-sha and exit 1, and writes no file. The flag is no longer dropped silently.

Intake: fixed by 8cea0acb 8cea0acb ("Generated docs and skill") generates `docs/commands/review-state.md` from the declaration registry. Its diff removes the `--git-sha` row from the `write` flag table and the line "All flags from `write` command, plus:". This is the second option in "Wanted": drop the row from the `write` table. Now only `update` lists `--git-sha` (`docs/commands/review-state.md:23`), and `update` honours it. Also, 7f1a97fe (#500) makes `write` refuse flags that it does not declare. On origin/main, `./iw review-state write --git-sha 1234567 ...` now stops with `Error: Unknown flag: --git-sha` and exit 1, and writes no file. The flag is no longer dropped silently.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
iterative-works/iw-cli#495
No description provided.