Skip to content

git rule misses common subcommands (checkout/merge/remote/cherry-pick/rebase/reset/tag/switch/restore) #84

Closed

Description

@thehoff

Symptom

The PreToolUse hook does not rewrite these git invocations:

Subcommand Count (30d) Live hook test
`git checkout` 76 no rewrite (exit 0, no JSON)
`git merge` 14 no rewrite
`git remote` 8 no rewrite
`git cherry-pick` 7 no rewrite

Verified:

```
$ echo '{..."command":"git checkout -b foo develop"}' | contextcrawler hook claude ; echo exit $?
exit 0
$ echo '{..."command":"git -c commit.gpgsign=false merge --no-ff foo"}' | contextcrawler hook claude ; echo exit $?
exit 0
```

Root cause

`src/discover/rules.rs:14-26`:

```rust
pattern: r"^(?:git|yadm)\s+(?:-[Cc]\s+\S+\s+)*(status|log|diff|show|add|commit|push|pull|branch|fetch|stash|worktree)"
```

The subcommand alternation is the closed set. Anything outside it bypasses both `classify_command` and `rewrite_command`.

Fix

Extend the alternation:

```rust
(status|log|diff|show|add|commit|push|pull|branch|fetch|stash|worktree|checkout|switch|restore|merge|rebase|reset|tag|remote|cherry-pick)
```

Important — this must land together with #84 (runtime GitCommand enum gap), otherwise the rewrite will route to a command `contextcrawler git checkout` that has no handler. Two options for #84:

  • Add explicit handlers with light filtering (e.g. `git checkout` is short, mostly passthrough)
  • Add a generic `GitCommand::Other(String)` variant that records tracking and execs raw

Acceptance

  • Hook smoke test: each new subcommand produces `updatedInput.command = "contextcrawler git …"`.
  • `classify_command("git checkout -b foo develop")` returns `Supported`.
  • Doesn't break existing `git -c commit.gpgsign=false merge …` global-opt handling (the regex `(?:-[Cc]\s+\S+\s+)*` already covers `-c k=v`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions