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
#!/usr/bin/env -S uv run python
from __future__ import annotations
import os
import sys
import pygit2
from pygittools.hooks import parse_ref_updates
from pygittools.hooks_notify import PostReceiveNotify
NOTIFY_URL = os.environ.get("PYGITWEB_NOTIFY_URL", "http://127.0.0.1:8000/_internal/notify")
PROJECT = os.environ.get("PYGITWEB_PROJECT") or os.path.basename(os.getcwd()).removesuffix(".git")
def main() -> int:
repo = pygit2.Repository(".")
updates = parse_ref_updates(sys.stdin)
result = PostReceiveNotify(repo, NOTIFY_URL, PROJECT).run(updates)
return int(result.value)
if __name__ == "__main__":
raise SystemExit(main())