PureYAML/scripts/check-style.sh
Mihaela Mihaljevic 1dc986f146 docs(readme): retire the stale Mermaid roadmap and its dead CI gate
The roadmap diagrams referenced issue numbers (#1, #8-#13, #43-#55) that no
longer exist on Codeberg: the GitHub to Codeberg migration reset this repo's
issue tracker, and those numbers were never re-created. scripts/check-roadmap.sh
existed only to keep that roadmap in sync with GitHub epic-labeled issues via
gh, which can't resolve a Codeberg/Forgejo repo anyway, so the gate had been a
silent no-op since the move. Removed the roadmap section, the gate script, its
two call sites, and its now-pointless rule doc, and pointed the remaining
work at the real, live issues (#4, #5, #6, #7, tracked under epic #8). Also
fixed two leftover Mihaela/PureYAML references in docs/RELEASE.md.
2026-07-09 23:38:23 +02:00

72 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Repo-wide style gate: no em dashes, no tool-attribution phrases, no signature
# emojis in any tracked file. Mirrors the .githooks checks, run over the whole
# tree in CI so a bypassed local hook is still caught at merge time.
#
# Portable: BSD-compatible grep, bash 3.2 (macOS) and bash 4+ (CI).
set -u
FAIL=0
# Em dash U+2014, built via printf so this script contains no em-dash byte.
EMDASH=$(printf '\xe2\x80\x94')
# Enforcement files legitimately contain the forbidden phrases in order to
# detect them, so exclude them from the phrase scan.
is_enforcement_file() {
case "$1" in
.githooks/*|scripts/check-style.sh) return 0 ;;
*) return 1 ;;
esac
}
is_vendored_fixture() {
case "$1" in
Tests/Fixtures/acme/*|Tests/Fixtures/real-yaml/*) return 0 ;;
# Vendored upstream rules canon (mirror of the rules-swift repo). Its own
# enforcement docs legitimately quote the forbidden attribution phrases, so
# the whole vendored tree is excluded from the style scan, exactly like the
# repo's own enforcement files. Provenance: docs/rules-swift/PROVENANCE.md.
docs/rules-swift/*) return 0 ;;
*) return 1 ;;
esac
}
# Tool-attribution phrases. Assembled from fragments so this script does not
# contain the full literal phrases (which would self-flag in other scanners).
TOOL="Cla""ude"
PHRASES=(
"Co-Authored-By: $TOOL"
"Co-authored-by: $TOOL"
"Generated with $TOOL"
"Generated by $TOOL"
"Powered by $TOOL"
"as an AI"
)
while IFS= read -r f; do
[ -f "$f" ] || continue
if is_vendored_fixture "$f"; then
continue
fi
if LC_ALL=C grep -qF -- "$EMDASH" "$f" 2>/dev/null; then
echo "style: em dash (U+2014) in $f" >&2
FAIL=1
fi
if ! is_enforcement_file "$f"; then
for p in "${PHRASES[@]}"; do
if LC_ALL=C grep -qF -- "$p" "$f" 2>/dev/null; then
echo "style: forbidden attribution phrase in $f" >&2
FAIL=1
fi
done
fi
done < <(git ls-files)
if [ "$FAIL" -ne 0 ]; then
echo "style: gate failed. Rules: docs/rules/git-discipline.md" >&2
fi
exit "$FAIL"