Skip to content

fix: support git -C <path> in rewrite registry#556

Closed
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/git-dash-c-rewrite
Closed

fix: support git -C <path> in rewrite registry#556
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/git-dash-c-rewrite

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

Summary

  • Fixes rtk rewrite not recognizing git -C <path> <subcommand> commands
  • Updates regex pattern to accept -C and -c flags before the git subcommand using a non-capturing group (?:-[Cc]\s+\S+\s+)*
  • Adds 4 tests: rewrite with -C for status/log/diff + classify verification

Before / After

# Before (exit 1, no rewrite):
rtk rewrite 'git -C /tmp status'        # → nothing

# After:
rtk rewrite 'git -C /tmp status'        # → rtk git -C /tmp status
rtk rewrite 'git -C /tmp log -5'        # → rtk git -C /tmp log -5
rtk rewrite 'git -C /tmp diff --name-only' # → rtk git -C /tmp diff --name-only

Test plan

  • 4 new tests for git -C support (rewrite + classify)
  • 156 existing registry tests still pass
  • git diff --cached not broken (non-capturing group preserves subcommand extraction)
  • Manual verification with cargo run -- rewrite

Closes #555

🤖 Generated with Claude Code

The regex pattern for git commands now accepts -C and -c flags
before the subcommand, using a non-capturing group to preserve
subcommand extraction.

Closes rtk-ai#555

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
Copy link
Copy Markdown
Contributor

@aeppling aeppling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — PR #556

Clean, well-scoped fix. 2 files, +43/-1, no unrelated changes. The regex change is backward compatible (zero-or-more match).

Verdict

Minimal, correct, non-breaking.

@aeppling
Copy link
Copy Markdown
Contributor

Benchmark cicd failed , need to be fix

@aeppling
Copy link
Copy Markdown
Contributor

Closing this PR and merging #547

@aeppling
Copy link
Copy Markdown
Contributor

#547

@aeppling aeppling closed this Mar 13, 2026
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.

2 participants