Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions git-hooks/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,13 @@ pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass \
Write-Host "Installed bash commit-msg hook → $HooksDir"
}

git config --global core.hooksPath $HooksDir
Write-Host "Global git hooks path set to: $HooksDir"
# Git for Windows bash requires POSIX drive notation (e.g. /c/Users/..., not C:\Users\...)
if ($HooksDir -match '^([A-Za-z]):[/\\](.*)$') {
$drive = $Matches[1].ToLower()
$rest = $Matches[2] -replace '\\', '/'
$posixHooksDir = "/$drive/$rest"
} else {
$posixHooksDir = $HooksDir -replace '\\', '/'
}
git config --global core.hooksPath $posixHooksDir
Write-Host "Global git hooks path set to: $posixHooksDir"
8 changes: 8 additions & 0 deletions git-hooks/tests/install.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Describe 'install.ps1 -UsePowerShell shim' {
}
}

It 'should convert Windows path to POSIX drive notation when setting core.hooksPath' {
if ($IsWindows) {
$configuredPath = git config --global core.hooksPath
$configuredPath | Should -Match '^/[a-z]/'
$configuredPath | Should -Not -Match '^[A-Za-z]:'
}
}

It 'should write the commit-msg shim without a UTF-8 BOM' {
$shimPath = Join-Path $tempDir 'commit-msg'
$shimPath | Should -Exist
Expand Down