Skip to content

fix: convert Windows path to POSIX notation for core.hooksPath#10

Merged
BenjaminMichaelis merged 2 commits into
mainfrom
copilot/fix-git-hook-path-issue
Mar 10, 2026
Merged

fix: convert Windows path to POSIX notation for core.hooksPath#10
BenjaminMichaelis merged 2 commits into
mainfrom
copilot/fix-git-hook-path-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

install.ps1 was writing a Windows-style path (e.g. C:\Users\...\git\hooks) to core.hooksPath. Git for Windows bash resolves hooks via that config and requires POSIX drive notation (/c/Users/.../git/hooks), so hooks silently failed to run.

Changes

  • git-hooks/install.ps1: Before setting core.hooksPath, convert any Windows drive-letter path to POSIX notation. Paths already in POSIX format (Linux/macOS) pass through unchanged.
# Before
git config --global core.hooksPath $HooksDir  # → C:\Users\...\git\hooks

# After
if ($HooksDir -match '^([A-Za-z]):[/\\](.*)$') {
    $drive = $Matches[1].ToLower()
    $rest  = $Matches[2] -replace '\\', '/'
    $posixHooksDir = "/$drive/$rest"           # → /c/Users/.../git/hooks
} else {
    $posixHooksDir = $HooksDir -replace '\\', '/'
}
git config --global core.hooksPath $posixHooksDir
  • git-hooks/tests/install.Tests.ps1: Add assertion that core.hooksPath is set to POSIX drive notation (/[a-z]/...) and does not contain C:-style prefix on Windows. Test is gated on $IsWindows so it is a no-op on Linux/macOS.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Git for Windows bash requires POSIX drive notation (e.g. /c/Users/...)
rather than Windows-style paths (C:\Users\...) for core.hooksPath.

- install.ps1: detect Windows drive-letter paths and rewrite them to
  POSIX notation before calling `git config --global core.hooksPath`
- install.Tests.ps1: add test verifying POSIX path is set on Windows

Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix git hook issue with path notation fix: convert Windows path to POSIX notation for core.hooksPath Mar 10, 2026
@BenjaminMichaelis BenjaminMichaelis marked this pull request as ready for review March 10, 2026 19:53
@BenjaminMichaelis BenjaminMichaelis merged commit b750eeb into main Mar 10, 2026
12 checks passed
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