1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Sample Hooks
Place these as desired in `.git/hooks/` WITHOUT the suffix.
You will just need UV with pygittools in your virtual environment.
## post-receive.notify and post-commit.notify
Wake pygitweb's long-poll subscribers (`updates=true`) on every push (server-side) and
every local commit (client-side). They share two environment variables:
- `PYGITWEB_NOTIFY_URL` — the running server's notify endpoint (default
`http://127.0.0.1:8000/_internal/notify`)
- `PYGITWEB_PROJECT` — project path as known to pygitweb (default: the bare repo's
directory name with `.git` stripped, or for non-bare clones the working-tree directory
name)
The pygitweb summary page can install both at once via the **Hooks** row (the `update`
bundle installs `post-commit.notify` and `post-receive.notify` together).
## pre-receive.protected-pattern
Reject pushes to protected refs when any newly introduced non-merge commit message does
not match a pattern. Merge commits are skipped by default; set `PYGITWEB_REJECT_MERGE_COMMITS=1`
to refuse merge commits and require squash or rebase instead.
Environment variables:
- `PYGITWEB_PROTECTED_REF_PATTERN` — refs to protect (default `^refs/heads/(main|master)$`)
- `PYGITWEB_COMMIT_MSG_PATTERN` — message regex (default `^(\S+): (.+)`)
- `PYGITWEB_REJECT_MERGE_COMMITS` — set to `1`/`true`/`yes` to reject merge commits