Skip to content

Instantly share code, notes, and snippets.

@metacoma
Created March 11, 2026 17:18
Show Gist options
  • Select an option

  • Save metacoma/9864a3ed6ff8ab4cd597e46060067ceb to your computer and use it in GitHub Desktop.

Select an option

Save metacoma/9864a3ed6ff8ab4cd597e46060067ceb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
LOG="/tmp/deny.log"
DENY_REPOS_FILE="/home/git/custom_hooks/cyrillic_deny_repos.txt"
PROJECT="${GL_PROJECT_PATH:-unknown}"
echo "=== $(date '+%F %T') push attempt ===" >> "$LOG"
echo "user=${GL_USERNAME:-unknown} project=$PROJECT" >> "$LOG"
deny_policy=0
if grep -Fxq "$PROJECT" "$DENY_REPOS_FILE" 2>/dev/null; then
deny_policy=1
echo "policy: no cyrillic and no spaces" >> "$LOG"
else
echo "policy: unrestricted" >> "$LOG"
fi
while read -r oldrev newrev refname
do
echo "ref: $refname oldrev=$oldrev newrev=$newrev" >> "$LOG"
files=$(git -c core.quotepath=false diff --name-only "$oldrev" "$newrev")
while read -r f
do
[ -z "$f" ] && continue
echo "file: $f" >> "$LOG"
if [[ "$deny_policy" -eq 1 ]]; then
if echo "$f" | grep -q '[А-Яа-яЁё]'; then
echo "DENY: cyrillic characters in $f" >> "$LOG"
echo "GL-HOOK-ERR: Cyrillic characters are not allowed: $f"
exit 1
fi
if [[ "$f" == *" "* ]]; then
echo "DENY: space in filename $f" >> "$LOG"
echo "GL-HOOK-ERR: spaces in filenames are not allowed: $f"
exit 1
fi
fi
done <<< "$files"
done
echo "push allowed" >> "$LOG"
echo >> "$LOG"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment