Fix Windows CI: use forward slashes in git hook shell scripts

Root cause: getBDCommand() returned .\bd.exe on Windows, but git hooks
run with sh on Git for Windows where backslashes are escape characters.
This caused .\bd.exe to become .bd.exe, breaking hook execution.

Fix: Always use forward-slash paths (./bd.exe) in shell scripts.
Forward slashes work on Windows and are sh-compatible.
This commit is contained in:
Steve Yegge
2025-11-02 10:52:30 -08:00
parent f0beba354e
commit ad53c0bf4f

View File

@@ -20,9 +20,10 @@ func getBDPath() string {
}
// getBDCommand returns the platform-specific command to run bd from current dir
// Always uses forward slashes for sh script compatibility (Git for Windows uses sh)
func getBDCommand() string {
if runtime.GOOS == "windows" {
return ".\\bd.exe"
return "./bd.exe"
}
return "./bd"
}
@@ -236,7 +237,8 @@ func resolveConflictMarkersIfPresent(t *testing.T, cloneDir string) {
func installGitHooks(t *testing.T, repoDir string) {
t.Helper()
hooksDir := filepath.Join(repoDir, ".git", "hooks")
bdCmd := getBDCommand()
// Ensure POSIX-style path for sh scripts (even on Windows)
bdCmd := strings.ReplaceAll(getBDCommand(), "\\", "/")
preCommit := fmt.Sprintf(`#!/bin/sh
%s --no-daemon export -o .beads/issues.jsonl >/dev/null 2>&1 || true