Skip to content

fix(go): rewrite and filter go -C DIR test, build and vet - #5392

Open
Kernel-Hunter wants to merge 1 commit into
rtk-ai:developfrom
Kernel-Hunter:fix-go-chdir-flag
Open

Kernel-Hunter wants to merge 1 commit into
rtk-ai:developfrom
Kernel-Hunter:fix-go-chdir-flag

Conversation

@Kernel-Hunter

Copy link
Copy Markdown

Summary

  • The rewrite rule only matched go test|build|vet, so go -C DIR test ./... was left alone and the full output reached the agent. Running rtk go -C DIR test by hand did not help either: clap rejected -C and the raw-exec fallback ran plain go, unfiltered.
  • The rule now accepts -C DIR, --C DIR, -C=DIR and --C=DIR before the subcommand. rtk go takes the same flag and puts -C DIR before the subcommand when it runs go, so -json is still injected after it. Other subcommands (go -C DIR mod tidy) are not rewritten, and go -C DIR tool .../list keep passing through with the flag.
  • rtk go test -C DIR (flag after the subcommand) behaves as before.

Test plan

  • New tests: rewrite of the four flag spellings plus a compound command, no rewrite for go -C ./sub mod tidy and a bare go -C test, and a clap parse test for the flag before the subcommand and as a plain argument after it.
  • Real Go module with one passing and one failing test: rtk go -C sub test ./... prints the compact failure summary and exits 1; -C=sub and --C=sub the same; rtk go -C sub vet/build run.
  • cargo fmt --all -- --check, cargo clippy --locked --all-targets and cargo test --locked --lib (5089 passed) pass on macOS.

Fixes #4970

The hook only matched go test|build|vet, so go -C DIR test was never rewritten, and rtk go -C DIR test fell back to the raw command. Accept the chdir flag in the rewrite rule and as an option of rtk go, and put it before the subcommand when running go.

Fixes rtk-ai#4970
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hook does not rewrite go -C DIR <subcommand> (global chdir flag before the subcommand)

1 participant