just: checking for ellipses

Add custom check for ellipses "...", asking for replacement of "…".

Git ranges and the CLI wildcard matches are ignored.

This change includes fixes to all sites that did not pass the check.
This commit is contained in:
Fintan Halpenny
2026-05-28 16:52:02 +01:00
parent 9c37511613
commit 9ff0e8b01f
33 changed files with 128 additions and 69 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ install() {
main() {
if [ $# -lt 2 ]; then
echo "usage: $0 <output-dir> <input-file>..."
echo "usage: $0 <output-dir> <input-file>…"
exit 1
fi
+54
View File
@@ -0,0 +1,54 @@
#! /usr/bin/env bash
set -euo pipefail
# Replace '...' with '…' (U+2026) in markdown, just and Rust files, but ignore:
# - Git ranges with hex hashes, e.g. 20aa5dd...f2de534
# - Git ranges with ref paths, e.g. feature/1...rad/patches/f2de534
# - Standalone '...' lines used as output wildcards in CLI example tests
# - Wildcards for CLI example tests, i.e. [...]
patterns=('*.md' '*.rs' '*justfile')
# Get all regular files (exclude symlinks, directories, etc.)
files=()
while IFS= read -r -d '' file; do
if [ -f "$file" ] && [ ! -L "$file" ]; then
files+=("$file")
fi
done < <(git ls-files -z "${patterns[@]}")
if [ ${#files[@]} -eq 0 ]; then
exit 0
fi
# Checksum files before sed so we detect only changes it makes.
before=$(printf '%s\0' "${files[@]}" | xargs -0 md5sum)
standalone_wildcard='^[[:space:]]*\.\.\.[[:space:]]*$'
git_hex_range='[0-9a-f]{4,}\.\.\.[0-9a-f]{4,}'
git_ref_range='[^[:space:]]*\/[^[:space:]]*\.\.\.[^[:space:]]*\/[^[:space:]]*'
bracket_wildcard='\[[[:space:]]*\.\.\.[[:space:]]*\]'
# Detect GNU vs BSD sed to apply the correct in-place flag
if sed --version >/dev/null 2>&1; then
sed_cmd=(sed -i -E)
else
sed_cmd=(sed -i '' -E)
fi
printf '%s\0' "${files[@]}" | xargs -0 "${sed_cmd[@]}" \
-e "/${standalone_wildcard}/b" \
-e "/${git_hex_range}/b" \
-e "/${git_ref_range}/b" \
-e "/${bracket_wildcard}/b" \
-e 's/\.\.\./…/g'
after=$(printf '%s\0' "${files[@]}" | xargs -0 md5sum)
changed=$(diff <(echo "$before") <(echo "$after") | grep '^>' | sed 's/^> [a-f0-9]* //' || true)
if [ -n "$changed" ]; then
echo "error: Replaced '...' with '…' (U+2026) in the following files:"
echo "$changed"
echo "Please commit these changes."
exit 1
fi
+1 -1
View File
@@ -1,6 +1,6 @@
#! /usr/bin/env bash
set -e
echo "${CHECK}Checking for forbidden words in staged files...${NORMAL}"
echo "${CHECK}Checking for forbidden words in staged files…${NORMAL}"
# Get staged Rust files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep '\.rs$' || true)