Skip to content

Commit 89115ff

Browse files
dmealingclaude
andcommitted
chore(hooks): load denylist from configurable private path (git config hooks.denyListPath)
Keeps the single source of truth in a private repo; the public hook + CLAUDE.md name no private project. Falls back to .githooks/deny-list.local, else generic patterns only. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d743232 commit 89115ff

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

.githooks/pre-commit

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ PATTERNS='/home/[A-Za-z0-9._-]+/|~/Development'
2323
# Legitimate matches to ignore (e.g. the published npm author email).
2424
ALLOW='doug@dougmealing\.com'
2525

26-
# Merge in private-name patterns from the untracked local denylist, if present.
26+
# Merge in private-name patterns from a denylist. Source priority:
27+
# 1) git config hooks.denyListPath -> point at your private denylist file (kept in a private repo)
28+
# 2) .githooks/deny-list.local -> untracked local file or symlink
29+
# If neither resolves, only the generic structural patterns above are enforced.
2730
ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo .)"
28-
DENY_FILE="$ROOT/.githooks/deny-list.local"
31+
DENY_FILE="$(git config --get hooks.denyListPath 2>/dev/null || true)"
32+
[ -z "$DENY_FILE" ] && DENY_FILE="$ROOT/.githooks/deny-list.local"
2933
if [ -f "$DENY_FILE" ]; then
3034
extra=$(grep -vE '^[[:space:]]*(#|$)' "$DENY_FILE" | paste -sd'|' -)
3135
[ -n "$extra" ] && PATTERNS="$PATTERNS|$extra"

CLAUDE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ Cross-language conformance fixtures live at `fixtures/conformance/` (45 fixtures
2828
- **No absolute local paths.** Never commit a developer's home path (e.g. `/home/<user>/…` or a `~/`-rooted path). Use repo-relative paths or placeholders (`<repo-root>`, `<consumer-repo>`) in command examples.
2929
- **Scan the staged diff** for both of the above and genericize anything found before committing.
3030

31-
A local pre-commit hook enforces this (`.githooks/pre-commit`). Activate it once per clone:
31+
A local pre-commit hook enforces this (`.githooks/pre-commit`). The committed hook names **no** private project: it enforces generic structural patterns (absolute home paths) and loads a private-name denylist from a path you configure (kept in a private repo, never here). One-time per clone:
3232

3333
```
3434
git config core.hooksPath .githooks
35+
git config hooks.denyListPath /path/to/your/private/denylist.txt
3536
```
3637

37-
It blocks commits whose added lines match the forbidden patterns (`git commit --no-verify` bypasses, discouraged). The published npm author email is the one allowed exception. When a new consumer/project name is worth guarding, add it to **both** this section and the hook's `PATTERNS`.
38+
It blocks commits whose added lines match (`git commit --no-verify` bypasses, discouraged); the npm author email is the one allowed exception. Guard a new private name by editing that private denylist (single source of truth) — never add real names to this public repo or the committed hook.
3839

3940
## Monorepo layout
4041

0 commit comments

Comments
 (0)