mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
Pin format.ps1 to Git Bash on Windows
A bare `bash` on Windows can resolve to the WSL launcher
(System32\bash.exe) ahead of Git Bash, running the pre-commit hook
inside a Linux distro. There the CRLF-checked-out script fails to parse
("$'\r': command not found"), and even with clean line endings the WSL
path would install a Linux dotnet-format instead of the Windows one.
Resolve Git Bash from git.exe's install location instead, the same
CRLF-tolerant shell git itself uses to run the hook; non-Windows
platforms keep using plain bash.
Assisted-by: Claude:claude-fable-5:Claude Code
This commit is contained in:
+11
-1
@@ -5,7 +5,17 @@ $ErrorActionPreference = 'Stop'
|
||||
$env:OPENSSL_ENABLE_SHA1_SIGNATURES = '1'
|
||||
Push-Location (Join-Path $PSScriptRoot '..')
|
||||
try {
|
||||
bash BuildTools/pre-commit --format
|
||||
# On Windows, a bare `bash` can resolve to the WSL launcher (System32\bash.exe),
|
||||
# which runs the hook inside a Linux distro where the CRLF-checked-out script
|
||||
# cannot even be parsed. Pin to Git Bash, the same CRLF-tolerant shell git
|
||||
# itself uses to run the pre-commit hook.
|
||||
$bash = if ($IsWindows) {
|
||||
Join-Path (Split-Path (Split-Path (Get-Command git).Source)) 'bin\bash.exe'
|
||||
}
|
||||
else {
|
||||
'bash'
|
||||
}
|
||||
& $bash BuildTools/pre-commit --format
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
|
||||
Reference in New Issue
Block a user