Files
LLeMbas-TTY/scripts/hygiene.sh
T
HomerandClaude Opus 5.5 9863428c64 LLeMbas TTY 1.0.0-beta.1: fork of WezTerm at 1026152aa
The first own commit on WezTerm's main, with its full history kept so
upstream can be merged in. Adds VERSION, CHANGELOG.md, a README preface,
our copyright line beside upstream's in LICENSE.md (MIT both), UPSTREAM
(the upstream commit last merged) and scripts/hygiene.sh, which checks
only what this fork adds since UPSTREAM. Nothing in the terminal changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H1bF3XAshtCGhF7TeLGcDk
2026-11-28 00:04:53 +00:00

53 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Nothing we add may name the private estate it was written on (the LLeMbas section rule:
# "everything public is current-state and estate-free"), as a check that runs on every push.
#
# This is a fork: WezTerm's own tree has example addresses of its own (ssh tests, docs), and those
# are upstream's, not ours. So the check reads only what this fork adds: every line added since the
# upstream commit named in `UPSTREAM` (moved on each merge from upstream). This file is the one place
# that may spell the patterns, and is skipped.
set -euo pipefail
cd "$(dirname "$0")/.."
base=$(tr -d '[:space:]' < UPSTREAM)
git cat-file -e "$base^{commit}" 2>/dev/null || { echo "hygiene: UPSTREAM names $base, which this clone does not have" >&2; exit 2; }
patterns=(
'houmeres'
'\b[a-z0-9-]+\.lan\b'
'\bCT ?2[0-9]{2}\b'
'\b10\.0\.0\.[0-9]+'
'\b192\.168\.[0-9]+\.[0-9]+'
'\bgamebox\b'
'\bthor\b'
)
# Added lines only, with their file, from the fork point to the working tree (staged or not).
added=$(git diff --no-color --unified=0 "$base" -- . ':(exclude)scripts/hygiene.sh' \
| awk '/^\+\+\+ b\//{file=substr($0,7); next} /^\+/ && !/^\+\+\+/{print file": "substr($0,2)}')
# And files not yet tracked, which a diff does not show.
while IFS= read -r -d '' f; do
[ "$f" = scripts/hygiene.sh ] && continue
[ -f "$f" ] || continue
added+=$'\n'$(awk -v f="$f" '{print f": "$0}' "$f")
done < <(git ls-files -z --others --exclude-standard)
found=0
for pattern in "${patterns[@]}"; do
# grep: 0 = matched, 1 = no match, anything else is an error and must not read as "clean".
set +e
hits=$(printf '%s\n' "$added" | grep -IEi -- "$pattern")
rc=$?
set -e
if [ "$rc" -eq 0 ]; then
printf '%s\n' "$hits"
echo "hygiene: the lines above match /$pattern/" >&2
found=1
elif [ "$rc" -ne 1 ]; then
echo "hygiene: grep failed on /$pattern/" >&2
exit 2
fi
done
[ "$found" -eq 0 ] && echo "hygiene: nothing private in what this fork adds (since ${base:0:9})"
exit "$found"