Skip to content

Instantly share code, notes, and snippets.

@metacoma
Created March 11, 2026 16:41
Show Gist options
  • Select an option

  • Save metacoma/5bcae0f65f18cf23e6486e3cdd058206 to your computer and use it in GitHub Desktop.

Select an option

Save metacoma/5bcae0f65f18cf23e6486e3cdd058206 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
LOG="/tmp/deny.log"
echo "=== $(date '+%F %T') push attempt ===" >> "$LOG"
echo "user=${GL_USERNAME:-unknown} project=${GL_PROJECT_PATH:-unknown}" >> "$LOG"
while read oldrev newrev refname
do
echo "ref: $refname oldrev=$oldrev newrev=$newrev" >> "$LOG"
files=$(git diff --name-only "$oldrev" "$newrev")
for f in $files
do
echo "file: $f" >> "$LOG"
# запрет xxx
if [[ "$f" == *xxx* ]]; then
echo "DENY: forbidden word xxx in $f" >> "$LOG"
echo "GL-HOOK-ERR: filename contains forbidden word 'xxx': $f"
exit 1
fi
# запрет кириллицы
if echo "$f" | grep -q '[А-Яа-яЁё]'; then
echo "DENY: cyrillic characters in $f" >> "$LOG"
echo "GL-HOOK-ERR: filename contains Cyrillic characters: $f"
exit 1
fi
done
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