[PR #603] [MERGED] fix: use git bash style paths for Claude hooks on Windows #606

Closed
opened 2026-03-02 04:14:06 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/git-ai-project/git-ai/pull/603
Author: @svarlamov
Created: 2/27/2026
Status: Merged
Merged: 2/27/2026
Merged by: @svarlamov

Base: mainHead: devin/1772167014-claude-hooks-git-bash-path


📝 Commits (3)

  • 268794e fix: use git bash style paths for Claude hooks on Windows
  • 024b269 style: fix rustfmt formatting
  • cf68154 fix: add separator for drive-relative paths in to_git_bash_path

📊 Changes

2 files changed (+124 additions, -6 deletions)

View changed files

📝 src/mdm/agents/claude_code.rs (+42 -6)
📝 src/mdm/utils.rs (+82 -0)

📄 Description

Summary

Claude Code migrated to running hooks in git bash shell on Windows. This means the binary path in hook commands needs to use MSYS/MinGW-style paths (/c/Users/Administrator/.git-ai/bin/git-ai.exe) instead of native Windows paths (C:\Users\Administrator\.git-ai\bin\git-ai.exe).

Changes:

  • Added to_git_bash_path() utility in utils.rs that converts X:\... paths to /x/... format. Non-Windows paths pass through unchanged.
  • Applied to_git_bash_path() in ClaudeCodeInstaller::install_hooks() when building the command strings written to ~/.claude/settings.json.
  • Added unit tests for the new function and updated existing Windows path tests in claude_code.rs.

Updates since last revision:

  • Fixed drive-relative path edge case: C:foo now correctly produces /c/foo instead of /cfoo (the second branch in to_git_bash_path now uses /{}/{} format). Added a dedicated test for this case.

Review & Testing Checklist for Human

  • Verify on actual Windows machine: All tests run on Linux with synthetic PathBuf strings. Confirm that to_git_bash_path produces correct output when get_current_binary_path() returns a real Windows path at runtime (e.g. after clean_path strips \\?\ prefix). Recommended: run git-ai install on Windows and inspect the resulting ~/.claude/settings.json to confirm paths look like /c/Users/....
  • Confirm other agents unaffected: Only claude_code.rs uses to_git_bash_path. Cursor, VS Code, and other agents still use binary_path.display() directly — verify this is intentional and those tools don't also need git bash paths.
  • to_git_bash_path is called unconditionally (not gated behind #[cfg(windows)]): On Linux/macOS, unix paths pass through unchanged (covered by tests). Verify this is the desired behavior vs. only converting on Windows.

Notes


Open with Devin

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/git-ai-project/git-ai/pull/603 **Author:** [@svarlamov](https://github.com/svarlamov) **Created:** 2/27/2026 **Status:** ✅ Merged **Merged:** 2/27/2026 **Merged by:** [@svarlamov](https://github.com/svarlamov) **Base:** `main` ← **Head:** `devin/1772167014-claude-hooks-git-bash-path` --- ### 📝 Commits (3) - [`268794e`](https://github.com/git-ai-project/git-ai/commit/268794e9301e5a70ddb83eab25ad0a46bf75aa2d) fix: use git bash style paths for Claude hooks on Windows - [`024b269`](https://github.com/git-ai-project/git-ai/commit/024b269fe04f89cff8614b4de8d0908b4bfc8332) style: fix rustfmt formatting - [`cf68154`](https://github.com/git-ai-project/git-ai/commit/cf6815486bbd57d9d09135e668471fa9f59e2ce2) fix: add separator for drive-relative paths in to_git_bash_path ### 📊 Changes **2 files changed** (+124 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/mdm/agents/claude_code.rs` (+42 -6) 📝 `src/mdm/utils.rs` (+82 -0) </details> ### 📄 Description ## Summary Claude Code migrated to running hooks in git bash shell on Windows. This means the binary path in hook commands needs to use MSYS/MinGW-style paths (`/c/Users/Administrator/.git-ai/bin/git-ai.exe`) instead of native Windows paths (`C:\Users\Administrator\.git-ai\bin\git-ai.exe`). **Changes:** - Added `to_git_bash_path()` utility in `utils.rs` that converts `X:\...` paths to `/x/...` format. Non-Windows paths pass through unchanged. - Applied `to_git_bash_path()` in `ClaudeCodeInstaller::install_hooks()` when building the command strings written to `~/.claude/settings.json`. - Added unit tests for the new function and updated existing Windows path tests in `claude_code.rs`. **Updates since last revision:** - Fixed drive-relative path edge case: `C:foo` now correctly produces `/c/foo` instead of `/cfoo` (the second branch in `to_git_bash_path` now uses `/{}/{}` format). Added a dedicated test for this case. ## Review & Testing Checklist for Human - [ ] **Verify on actual Windows machine**: All tests run on Linux with synthetic `PathBuf` strings. Confirm that `to_git_bash_path` produces correct output when `get_current_binary_path()` returns a real Windows path at runtime (e.g. after `clean_path` strips `\\?\` prefix). Recommended: run `git-ai install` on Windows and inspect the resulting `~/.claude/settings.json` to confirm paths look like `/c/Users/...`. - [ ] **Confirm other agents unaffected**: Only `claude_code.rs` uses `to_git_bash_path`. Cursor, VS Code, and other agents still use `binary_path.display()` directly — verify this is intentional and those tools don't also need git bash paths. - [ ] **`to_git_bash_path` is called unconditionally** (not gated behind `#[cfg(windows)]`): On Linux/macOS, unix paths pass through unchanged (covered by tests). Verify this is the desired behavior vs. only converting on Windows. ### Notes - Requested by @svarlamov - [Link to Devin run](https://app.devin.ai/sessions/8e73a7c76c55486ea1addc5a12386a76) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/603" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 04:14:06 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
starred/git-ai#606
No description provided.