#!/bin/sh # commit-msg — refuse a message that names a locale. # # Every commit message on `main` is published verbatim on ftstore.app: the # subject in the activity list, the body in the popup behind it. Naming the # language a string was translated into says roughly where the person writing it # lives, which is the one thing the whole "nothing about the author" rule in # the project guide exists to prevent. See the section "Commit messages on `main` are # PUBLIC" there for the reasoning. # # This hook exists because that rule was the only one in the guide with no way # to check it, and it got broken twice in one session by someone who had read # it. Prose that describes a rule is not the same as a thing that enforces one. # # Escape hatch: `git commit --no-verify`. It is here because a hook that cannot # be overridden gets deleted rather than argued with, not because there is a # good reason to name a locale. msg_file="$1" [ -f "$msg_file" ] || exit 0 # Strip comments and the diff `--verbose` appends, so neither can trip this. body=$(sed -e '/^#/d' -e '/^diff --git /,$d' "$msg_file") # Language names, whole word, case-insensitive. Locale *codes* are deliberately # not matched: "de" and "en" appear inside ordinary words often enough that the # false alarms would train everyone to pass --no-verify by reflex. languages='German|Deutsch|English|Englisch|French|Français|Francais|Spanish|Español|Espanol|Italian|Italiano|Portuguese|Português|Portugues|Brazilian|Russian|Русский|Turkish|Türkçe|Turkce|Polish|Polski|Czech|Čeština|Cestina|Arabic|العربية|Persian|Farsi|فارسی|Thai|ไทย|Vietnamese|Việt|Indonesian|Bahasa|Chinese|中文|Mandarin|Simplified|Japanese|日本語|Korean|한국어' hits=$(printf '%s\n' "$body" | grep -inE "\\b($languages)\\b" || true) if [ -n "$hits" ]; then cat >&2 <