| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright (c) 2026 UtopiaIA |
| 4 | # |
| 5 | # Fails if the repository would publish data that identifies a machine or a |
| 6 | # person: home-directory paths in tracked files, co-author or tool-attribution |
| 7 | # trailers in history, or maintainer commits without the noreply address. |
| 8 | # CI runs it on every push; run it locally before pushing too. |
| 9 | set -euo pipefail |
| 10 | |
| 11 | status=0 |
| 12 | report() { |
| 13 | echo "privacy-check: $1" >&2 |
| 14 | status=1 |
| 15 | } |
| 16 | |
| 17 | # 1. Home-directory paths in tracked text files. CI runner paths are fine. |
| 18 | if hits=$(git grep -nIE '/(Users|home)/[A-Za-z0-9._-]+/' -- . ':(exclude)scripts/privacy-check.sh' | |
| 19 | grep -vE '/[h]ome/runner/'); then |
| 20 | echo "$hits" >&2 |
| 21 | report "home-directory paths in tracked files" |
| 22 | fi |
| 23 | |
| 24 | # 2. Co-author and tool-attribution trailers anywhere in history. |
| 25 | if git log --format=%B | grep -qiE '^co-authored-by:|generated with .*claude'; then |
| 26 | report "attribution trailer in a commit message" |
| 27 | fi |
| 28 | |
| 29 | # 3. The maintainer account commits with its noreply address only. |
| 30 | if bad=$(git log --format='%an <%ae>%n%cn <%ce>' | sort -u | grep -E '^KikoCis <' | |
| 31 | grep -v '<KikoCis@users.noreply.github.com>$'); then |
| 32 | echo "$bad" >&2 |
| 33 | report "maintainer identity without the noreply address" |
| 34 | fi |
| 35 | |
| 36 | if [ "$status" -eq 0 ]; then |
| 37 | echo "privacy-check: clean" |
| 38 | fi |
| 39 | exit "$status" |