Skip to content

Commit 1b6584f

Browse files
ci: add no-Cyrillic gate for commits and tracked files (WP-415)
English-only repository: block any push or PR introducing Cyrillic characters in commit messages or tracked file content. Mirrors the existing gate already proven in the aisystant->iwesys translation pipeline (translate-sync.yml). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 8b65c4e commit 1b6584f

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: No-Cyrillic Gate
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
no-cyrillic:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Resolve diff range
16+
id: range
17+
run: |
18+
if [ "${{ github.event_name }}" = "pull_request" ]; then
19+
base="${{ github.event.pull_request.base.sha }}"
20+
head="${{ github.event.pull_request.head.sha }}"
21+
else
22+
base="${{ github.event.before }}"
23+
head="${{ github.event.after }}"
24+
case "$base" in
25+
""|0000000000000000000000000000000000000000)
26+
base="$(git rev-list --max-parents=0 "$head" | tail -1)" ;;
27+
esac
28+
# A force-push (amend/rebase) rewrites history, so "before" can
29+
# point at a commit this fetch no longer has -- git diff/log would
30+
# fail with "bad object" instead of reporting the real change.
31+
# Fall back to the new commit's own parent, which still answers
32+
# "what did this push actually add" after the rewrite.
33+
if ! git cat-file -e "${base}^{commit}" 2>/dev/null; then
34+
base="$(git rev-parse "${head}^" 2>/dev/null || git rev-list --max-parents=0 "$head" | tail -1)"
35+
fi
36+
fi
37+
echo "base=$base" >> "$GITHUB_OUTPUT"
38+
echo "head=$head" >> "$GITHUB_OUTPUT"
39+
40+
- name: Cyrillic gate — new lines introduced by this change
41+
# Scoped to the diff, not the whole tree: these repositories carry
42+
# pre-existing Cyrillic (legacy comments/docs); the gate blocks new
43+
# drift going forward, not retroactive cleanup nobody asked for.
44+
# The range is written as a hex Unicode escape, not literal Cyrillic
45+
# letters, so the gate's own source file never trips its own check.
46+
run: |
47+
base="${{ steps.range.outputs.base }}"
48+
head="${{ steps.range.outputs.head }}"
49+
added=$(git diff "$base" "$head" -- . | grep -P '^\+[^+]' | grep -P '[\x{0400}-\x{04FF}\x{0500}-\x{052F}]' || true)
50+
if [ -n "$added" ]; then
51+
echo '::error::New Cyrillic text introduced by this change -- this repository is English-only going forward.'
52+
printf '%s\n' "$added"
53+
exit 1
54+
fi
55+
echo 'PASS: no new Cyrillic introduced.'
56+
57+
- name: Cyrillic gate — commit messages
58+
run: |
59+
base="${{ steps.range.outputs.base }}"
60+
head="${{ steps.range.outputs.head }}"
61+
messages="$(git log "$base..$head" --format=%B)"
62+
if printf '%s' "$messages" | grep -qP '[\x{0400}-\x{04FF}\x{0500}-\x{052F}]'; then
63+
echo '::error::Commit message contains Cyrillic -- this repository is English-only going forward.'
64+
exit 1
65+
fi
66+
echo 'PASS: commit messages contain no Cyrillic.'

0 commit comments

Comments
 (0)