mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-08 08:53:43 +08:00
The *.sh eol=lf rule landed via #1314, but the git hooks (scripts/git-hooks/commit-msg, scripts/hooks/pre-commit) are extensionless and were still at the mercy of core.autocrlf. Add their explicit entries, plus the contract test from #1272 wired as scripts/test.sh Step 0t: every shell entrypoint (*.sh + both hook directories) must carry an eol=lf attribute, with a matched-zero-files guard so a broken glob can never pass vacuously. Distilled from #1272: the diagnosis (CRLF checkouts breaking shebangs under WSL/MSYS), the hook-file coverage, and the guard design are @xumian520's; verified RED without the *.sh rule (105 uncovered entrypoints) and green with it (107 files). Co-Authored-By: xumian520 <126989134+xumian520@users.noreply.github.com> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
41 lines
1.2 KiB
Bash
41 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Regression guard: shell entrypoints must remain LF in Windows checkouts so
|
|
# they can run directly from WSL and MSYS without a `bash\r` shebang failure.
|
|
#
|
|
# Distilled from PR #1272 by @xumian520, who both hit the breakage under
|
|
# core.autocrlf=true and wrote this contract so it stays fixed. The .sh rule
|
|
# itself landed via #1314; the extensionless git hooks need their own
|
|
# entries, which this guard also covers.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
failures=0
|
|
checked=0
|
|
while IFS= read -r -d '' path &&
|
|
IFS= read -r -d '' attribute &&
|
|
IFS= read -r -d '' eol; do
|
|
checked=$((checked + 1))
|
|
if [[ "$eol" != "lf" ]]; then
|
|
echo "FAIL: $path must declare eol=lf (got ${eol:-unset})" >&2
|
|
failures=$((failures + 1))
|
|
fi
|
|
done < <(
|
|
git ls-files -z '*.sh' 'scripts/git-hooks/*' 'scripts/hooks/*' |
|
|
git check-attr -z --stdin eol
|
|
)
|
|
|
|
if ((checked == 0)); then
|
|
echo "FAIL: the line-ending contract matched no files — the glob set is broken" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ((failures > 0)); then
|
|
echo "FAIL: $failures shell entrypoint(s) lack an LF checkout contract" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Shell line-ending contract passed ($checked files)"
|