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§
- Hook
Kind - 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.Nonefor an unknown name. - hook_
names - The names
kindinstalls. - install
- Install the hooks. Writes to
out; never panics. - is_
drep_ managed - True when
bodyis 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.