From 118f3679a38d0b346cd4c6bc4187e10bf3743e01 Mon Sep 17 00:00:00 2001 From: Kaushik N <145863267+MrTig-afk@users.noreply.github.com> Date: Sun, 16 Aug 2026 19:55:30 +1000 Subject: [PATCH] fix(lefthook): run the conflict-marker check on Windows (#3320) Co-authored-by: Claude Opus 5 (1M context) --- lefthook.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lefthook.yml b/lefthook.yml index c9265b3c7..dd82f4c90 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -9,13 +9,20 @@ pre-commit: exclude: - "*.md" - "*.mdx" + # Single quotes only: on Windows the script is truncated at the first double quote, which + # leaves the shell with an unterminated command and fails the job on every commit. + # grep exits 1 for a clean tree and 2 on error, so the statuses are handled separately — + # an unreadable path must fail the job rather than read as no markers found. run: | - matches=$(grep -nEI '<{7} |>{7} |^={7}$' {staged_files} || true) - if [ -n "$matches" ]; then - echo "$matches" - echo "Error: merge conflict markers found in staged files" - exit 1 + grep -nEI '<{7} |>{7} |^={7}$' {staged_files} + status=$? + if [ $status -eq 1 ]; then + exit 0 + elif [ $status -ne 0 ]; then + exit $status fi + echo 'Error: merge conflict markers found in staged files' + exit 1 - name: lint and format glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}" run: pnpm biome check --write --unsafe --no-errors-on-unmatched --files-ignore-unknown=true {staged_files}