@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 52 lines 2.2 kB view raw
1@title Diffusion User Guide: Commit Hooks 2@group userguide 3 4Guide to commit hooks in hosted repositories. 5 6= Overview = 7 8Phorge installs pre-receive/pre-commit hooks in hosted repositories 9automatically. They enforce a few rules automatically (like preventing 10dangerous changes unless a repository is configured to allow them). They can 11also enforce more complex rules via Herald, using the "Commit Hook: 12Branches/Tags/Bookmarks" and "Commit Hook: Commit Content" rule types. 13 14Herald rules are flexible, and can express many of the most common hooks that 15are often installed on repositories (like protecting branches, restricting 16access to repositories, and requiring review). 17 18However, if Herald isn't powerful enough to enforce everything you want to 19check, you can install additional custom hooks. These work mostly like normal 20hooks, but with a few differences. 21 22= Installing Custom Hooks = 23 24With hosted repositories, you can install hooks by dropping them into the 25relevant directory of the repository on disk: 26 27 - **SVN** Put hooks in `hooks/pre-commit-phabricator.d/`. 28 - **Git** Put hooks in `hooks/pre-receive-phabricator.d/`. 29 - **Mercurial** Phorge does not currently support custom hooks in 30 Mercurial. 31 32These hooks act like normal `pre-commit` or `pre-receive` hooks: 33 34 - Executables in these directories will be run one at a time, in alphabetical 35 order. 36 - They'll be passed the arguments and environment that normal hooks are 37 passed. 38 - They should emit output and return codes like normal hooks do. 39 - These hooks will run only after all the Herald rules have passed and 40 Phorge is otherwise ready to accept the commit or push. 41 42These additional variables will be available in the environment, in addition 43to the variables the VCS normally provides: 44 45 - `PHABRICATOR_REPOSITORY` The PHID of the repository the hook is 46 executing for. 47 - `PHABRICATOR_USER` The Phorge username that the session is 48 authenticated under. 49 - `PHABRICATOR_REMOTE_ADDRESS` The connection's remote address (that is, 50 the IP address of whoever is pushing or committing). 51 - `PHABRICATOR_REMOTE_PROTOCOL` The protocol the connection is using (for 52 example, "ssh" or "http").