Skip to content

Commit 9f10eca

Browse files
authored
Merge pull request #223 from PsychQuant/idd/216-gitattributes-line-ending-policy
chore: add .gitattributes line-ending policy — LF global + CRLF fixture exemption + regression lock
2 parents 3710f42 + 25fa678 commit 9f10eca

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"issue": 216,
3+
"fetched_at": "2026-07-05T05:47:21Z",
4+
"fetched_by": "idd-diagnose",
5+
"files": []
6+
}

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Line-ending policy (#216): all text files normalize to LF in index and checkout.
2+
# Prevents whole-file CRLF churn like the diffs caught in #214 R1/R2 verify.
3+
* text=auto eol=lf
4+
5+
# Deliberate CRLF test fixtures are exempt from text handling via -text (text unset).
6+
# Note: `git check-attr -a` may still report `eol: lf` from the global rule above —
7+
# that attribute is inert when `text` is unset; the CRLF bytes are preserved.
8+
# Convention: any future fixture that must keep CRLF bytes adds its own -text line here.
9+
# Regression lock: plugins/issue-driven-dev/scripts/tests/git-attributes/test.sh
10+
plugins/issue-driven-dev/scripts/tests/idd-edit/fixtures/19-section-replace-crlf/input.md -text
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
# test.sh — regression lock for the repo line-ending policy (#216)
3+
#
4+
# Locks the two load-bearing facts of .gitattributes:
5+
# 1. The deliberate CRLF fixture keeps its CRLF bytes (the -text exemption is
6+
# present AND effective). Without this lock, deleting the -text line would
7+
# silently degrade fixture 19-section-replace-crlf from a CRLF test into an
8+
# LF test with no failing test anywhere (#216 verify, devils-advocate finding).
9+
# 2. The global `* text=auto eol=lf` policy line exists, so newly added CRLF
10+
# text files normalize to LF in the index.
11+
#
12+
# Read-only: no index/working-tree mutation (safe to run with staged changes).
13+
14+
set -u
15+
16+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../../.." && pwd)"
17+
FIXTURE="plugins/issue-driven-dev/scripts/tests/idd-edit/fixtures/19-section-replace-crlf/input.md"
18+
PASS=0
19+
FAIL=0
20+
21+
check() { # <label> <cmd...>
22+
local label="$1"; shift
23+
if "$@" > /dev/null 2>&1; then
24+
echo "$label"; PASS=$((PASS + 1))
25+
else
26+
echo "$label"; FAIL=$((FAIL + 1))
27+
fi
28+
}
29+
30+
cd "$REPO_ROOT" || { echo "✗ cannot cd to repo root"; exit 1; }
31+
32+
# 1a. .gitattributes exists with the global LF policy line
33+
check "policy: .gitattributes has global '* text=auto eol=lf'" \
34+
grep -qE '^\* text=auto eol=lf$' .gitattributes
35+
36+
# 1b. the CRLF fixture has an explicit -text exemption line
37+
check "policy: fixture has -text exemption line" \
38+
grep -qF "$FIXTURE -text" .gitattributes
39+
40+
# 2. attribute resolution: text must be UNSET for the fixture (exemption effective)
41+
TEXT_ATTR="$(git check-attr text -- "$FIXTURE" | awk -F': ' '{print $NF}')"
42+
check "check-attr: fixture 'text' resolves to unset (got: $TEXT_ATTR)" \
43+
test "$TEXT_ATTR" = "unset"
44+
45+
# 3. index state: fixture is stored with CRLF (i/crlf)
46+
INDEX_EOL="$(git ls-files --eol -- "$FIXTURE" | awk '{print $1}')"
47+
check "index: fixture stored as i/crlf (got: $INDEX_EOL)" \
48+
test "$INDEX_EOL" = "i/crlf"
49+
50+
# 4. working copy bytes: fixture actually contains CRLF sequences
51+
check "worktree: fixture bytes contain CRLF" \
52+
grep -q $'\r' "$FIXTURE"
53+
54+
echo "================================"
55+
echo "Results: $PASS passed, $FAIL failed"
56+
[ "$FAIL" -eq 0 ]

0 commit comments

Comments
 (0)