Skip to content

Commit 39bd040

Browse files
authored
Merge pull request DeusData#1699 from DeusData/fix/lf-endings-distill
fix(build): LF contract for extensionless git hooks + a line-ending guard
2 parents 00beec9 + 32633ba commit 39bd040

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

‎.gitattributes‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@
55
# Vendored tree-sitter grammars — machine-generated, hide from stats and diffs
66
internal/cbm/vendored/grammars/**/parser.c linguist-generated=true diff=false
77
internal/cbm/vendored/grammars/**/scanner.c linguist-generated=true diff=false
8+
9+
# Shell entrypoints must check out LF everywhere: a CRLF shebang line breaks
10+
# them under WSL/MSYS (`bash\r: no such file`). The *.sh rule covers scripts;
11+
# the git hooks are extensionless and need explicit entries. (#1272)
12+
scripts/git-hooks/commit-msg text eol=lf
13+
scripts/hooks/pre-commit text eol=lf

‎scripts/test.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ bash "$ROOT/tests/test_release_gate_chain_contract.sh"
260260
echo "=== Step 0t: test runtime isolation contract (#1691) ==="
261261
bash "$ROOT/tests/test_runtime_isolation_contract.sh"
262262

263+
echo "=== Step 0u: shell line-ending contract ==="
264+
bash "$ROOT/tests/test_shell_line_endings.sh"
265+
263266
# Verify compiler supports target arch
264267
verify_compiler "$CC"
265268

‎tests/test_shell_line_endings.sh‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
# Regression guard: shell entrypoints must remain LF in Windows checkouts so
3+
# they can run directly from WSL and MSYS without a `bash\r` shebang failure.
4+
#
5+
# Distilled from PR #1272 by @xumian520, who both hit the breakage under
6+
# core.autocrlf=true and wrote this contract so it stays fixed. The .sh rule
7+
# itself landed via #1314; the extensionless git hooks need their own
8+
# entries, which this guard also covers.
9+
10+
set -euo pipefail
11+
12+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
13+
cd "$ROOT"
14+
15+
failures=0
16+
checked=0
17+
while IFS= read -r -d '' path &&
18+
IFS= read -r -d '' attribute &&
19+
IFS= read -r -d '' eol; do
20+
checked=$((checked + 1))
21+
if [[ "$eol" != "lf" ]]; then
22+
echo "FAIL: $path must declare eol=lf (got ${eol:-unset})" >&2
23+
failures=$((failures + 1))
24+
fi
25+
done < <(
26+
git ls-files -z '*.sh' 'scripts/git-hooks/*' 'scripts/hooks/*' |
27+
git check-attr -z --stdin eol
28+
)
29+
30+
if ((checked == 0)); then
31+
echo "FAIL: the line-ending contract matched no files — the glob set is broken" >&2
32+
exit 1
33+
fi
34+
35+
if ((failures > 0)); then
36+
echo "FAIL: $failures shell entrypoint(s) lack an LF checkout contract" >&2
37+
exit 1
38+
fi
39+
40+
echo "Shell line-ending contract passed ($checked files)"

0 commit comments

Comments
 (0)