Changeset View
Changeset View
Standalone View
Standalone View
src/docs/user/userguide/diffusion_hooks.diviner
@title Diffusion User Guide: Commit Hooks | @title Diffusion User Guide: Commit Hooks | ||||
@group userguide | @group userguide | ||||
Guide to commit hooks in hosted repositories. | Guide to commit hooks in hosted repositories. | ||||
= Overview = | = Overview = | ||||
Phabricator installs pre-receive/pre-commit hooks in hosted repositories | Phorge installs pre-receive/pre-commit hooks in hosted repositories | ||||
automatically. They enforce a few rules automatically (like preventing | automatically. They enforce a few rules automatically (like preventing | ||||
dangerous changes unless a repository is configured to allow them). They can | dangerous changes unless a repository is configured to allow them). They can | ||||
also enforce more complex rules via Herald, using the "Commit Hook: | also enforce more complex rules via Herald, using the "Commit Hook: | ||||
Branches/Tags/Bookmarks" and "Commit Hook: Commit Content" rule types. | Branches/Tags/Bookmarks" and "Commit Hook: Commit Content" rule types. | ||||
Herald rules are flexible, and can express many of the most common hooks that | Herald rules are flexible, and can express many of the most common hooks that | ||||
are often installed on repositories (like protecting branches, restricting | are often installed on repositories (like protecting branches, restricting | ||||
access to repositories, and requiring review). | access to repositories, and requiring review). | ||||
However, if Herald isn't powerful enough to enforce everything you want to | However, if Herald isn't powerful enough to enforce everything you want to | ||||
check, you can install additional custom hooks. These work mostly like normal | check, you can install additional custom hooks. These work mostly like normal | ||||
hooks, but with a few differences. | hooks, but with a few differences. | ||||
= Installing Custom Hooks = | = Installing Custom Hooks = | ||||
With hosted repositories, you can install hooks by dropping them into the | With hosted repositories, you can install hooks by dropping them into the | ||||
relevant directory of the repository on disk: | relevant directory of the repository on disk: | ||||
- **SVN** Put hooks in `hooks/pre-commit-phabricator.d/`. | - **SVN** Put hooks in `hooks/pre-commit-phabricator.d/`. | ||||
- **Git** Put hooks in `hooks/pre-receive-phabricator.d/`. | - **Git** Put hooks in `hooks/pre-receive-phabricator.d/`. | ||||
- **Mercurial** Phabricator does not currently support custom hooks in | - **Mercurial** Phorge does not currently support custom hooks in | ||||
Mercurial. | Mercurial. | ||||
These hooks act like normal `pre-commit` or `pre-receive` hooks: | These hooks act like normal `pre-commit` or `pre-receive` hooks: | ||||
- Executables in these directories will be run one at a time, in alphabetical | - Executables in these directories will be run one at a time, in alphabetical | ||||
order. | order. | ||||
- They'll be passed the arguments and environment that normal hooks are | - They'll be passed the arguments and environment that normal hooks are | ||||
passed. | passed. | ||||
- They should emit output and return codes like normal hooks do. | - They should emit output and return codes like normal hooks do. | ||||
- These hooks will run only after all the Herald rules have passed and | - These hooks will run only after all the Herald rules have passed and | ||||
Phabricator is otherwise ready to accept the commit or push. | Phorge is otherwise ready to accept the commit or push. | ||||
These additional variables will be available in the environment, in addition | These additional variables will be available in the environment, in addition | ||||
to the variables the VCS normally provides: | to the variables the VCS normally provides: | ||||
- `PHABRICATOR_REPOSITORY` The PHID of the repository the hook is | - `PHABRICATOR_REPOSITORY` The PHID of the repository the hook is | ||||
executing for. | executing for. | ||||
- `PHABRICATOR_USER` The Phabricator username that the session is | - `PHABRICATOR_USER` The Phorge username that the session is | ||||
authenticated under. | authenticated under. | ||||
- `PHABRICATOR_REMOTE_ADDRESS` The connection's remote address (that is, | - `PHABRICATOR_REMOTE_ADDRESS` The connection's remote address (that is, | ||||
the IP address of whoever is pushing or committing). | the IP address of whoever is pushing or committing). | ||||
- `PHABRICATOR_REMOTE_PROTOCOL` The protocol the connection is using (for | - `PHABRICATOR_REMOTE_PROTOCOL` The protocol the connection is using (for | ||||
example, "ssh" or "http"). | example, "ssh" or "http"). |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0