@@ -52,37 +52,48 @@ jobs:
5252 exit 0
5353 fi
5454
55- GREP_FILTER='grep -v "^---" | grep -v "^-exports\[" | grep -v "^-$" | grep -v "^\-[[:space:]]*$" | grep -v "^\-\`;$"'
55+ # Detect truly removed API lines by comparing deleted vs added lines.
56+ # Lines that appear in both deleted and added sets are modifications or
57+ # snapshot reorganizations (due to index.d.ts duplication), not removals.
58+ # Only lines present in deleted but NOT in added are real breaking changes.
59+ extract_truly_deleted() {
60+ local diff_output="$1"
61+ local noise_filter='grep -v "^exports\[" | grep -v "^$" | grep -v "^[[:space:]]*$" | grep -v "^\`;" | grep -v "^[[:space:]]*}[;,]\?$" | grep -v "^export { }$" | grep -v "^[[:space:]]*static readonly version" | grep -v "^export { .*_[0-9]\+ as "'
62+
63+ # Extract deleted lines (strip leading -, normalize quotes and Object casing)
64+ local deleted
65+ deleted=$(echo "$diff_output" | grep '^-' | grep -v '^---' | sed 's/^-//' \
66+ | eval "$noise_filter" | sed "s/\"/'/g; s/\bObject\b/object/g" | sort -u || true)
67+
68+ # Extract added lines (strip leading +, normalize quotes and Object casing)
69+ local added
70+ added=$(echo "$diff_output" | grep '^+' | grep -v '^+++' | sed 's/^+//' \
71+ | eval "$noise_filter" | sed "s/\"/'/g; s/\bObject\b/object/g" | sort -u || true)
72+
73+ # Lines in deleted but NOT in added = truly removed
74+ if [ -n "$deleted" ]; then
75+ comm -23 <(echo "$deleted") <(echo "$added") || true
76+ fi
77+ }
5678
5779 # 1) Committed snapshot changes (BASE...HEAD)
58- COMMITTED_DELETED =""
80+ COMMITTED_REMOVED =""
5981 if git diff --name-only "$BASE_REF"...HEAD | grep -q "$SNAP_FILE"; then
60- COMMITTED_DELETED=$(git diff "$BASE_REF"...HEAD -- "$SNAP_FILE" \
61- | grep '^-' \
62- | grep -v '^---' \
63- | grep -v '^-exports\[' \
64- | grep -v '^-$' \
65- | grep -v '^\-[[:space:]]*$' \
66- | grep -v '^\-`;$' \
67- || true)
82+ DIFF_OUTPUT=$(git diff "$BASE_REF"...HEAD -- "$SNAP_FILE")
83+ COMMITTED_REMOVED=$(extract_truly_deleted "$DIFF_OUTPUT")
6884 fi
6985
7086 # 2) Uncommitted snapshot changes: the -u step regenerated the snapshot
7187 # from current code; diff HEAD vs working tree catches type changes
7288 # that were not committed as snapshot updates.
73- UNCOMMITTED_DELETED =""
89+ UNCOMMITTED_REMOVED =""
7490 if ! git diff --quiet HEAD -- "$SNAP_FILE" 2>/dev/null; then
75- UNCOMMITTED_DELETED=$(git diff HEAD -- "$SNAP_FILE" \
76- | grep '^-' \
77- | grep -v '^---' \
78- | grep -v '^-exports\[' \
79- | grep -v '^-$' \
80- | grep -v '^\-[[:space:]]*$' \
81- | grep -v '^\-`;$' \
82- || true)
91+ DIFF_OUTPUT=$(git diff HEAD -- "$SNAP_FILE")
92+ UNCOMMITTED_REMOVED=$(extract_truly_deleted "$DIFF_OUTPUT")
8393 fi
8494
85- DELETED_LINES="${COMMITTED_DELETED}${UNCOMMITTED_DELETED}"
95+ # Merge and deduplicate across both sources
96+ DELETED_LINES=$(printf '%s\n%s' "$COMMITTED_REMOVED" "$UNCOMMITTED_REMOVED" | grep -v '^$' | sort -u || true)
8697
8798 if [ -z "$DELETED_LINES" ]; then
8899 echo "No DTS API breaking changes detected."
0 commit comments