Skip to main content

Module hooks

Module hooks 

Source
Expand description

drep init’s git-hook installer.

This is the only part of drep init that can damage something. It writes into .git/hooks/, which the user owns, so every branch below is deliberate: a foreign hook is left alone, a chainer is rewritten only when it does not already chain, and core.hooksPath is resolved the way git resolves it (relative to the repository, not the cwd).

Two hooks are installed today: pre-commit (one drep check --staged) and pre-push (one drep check --push-gate --diff <remote-oid> per ref on stdin). Both begin with # Managed by \drep init`.` - that marker is how this module recognises a hook it wrote and may rewrite.

Enums§

HookKind
Which git hook to install.

Constants§

MANAGED_MARKER
PRE_COMMIT_BODY
The body drep writes for pre-commit.
PRE_PUSH_BODY
The body drep writes for pre-push.

Functions§

chainer_body
The chainer body, parameterised on the hook name.
hook_body
The body drep writes for name. None for an unknown name.
hook_names
The names kind installs.
install
Install the hooks. Writes to out; never panics.
is_drep_managed
True when body is a hook drep wrote and may therefore rewrite.
resolve_hooks_dir
core.hooksPath, resolved the way git resolves it: an absolute value is used as-is, a relative one is relative to the repository, not the cwd.