Skip to main content

Module install

Module install 

Source
Expand description

amont install — put the binary somewhere stable and wire up the shims.

This was a Makefile recipe. It moved here for one reason: the guard below decides whether a directory is safe to delete, it has been got wrong TWICE — both times overwriting tracked source files with machine-specific paths — and shell that runs on one platform cannot be tested on three.

Everything here is std. The commit path’s dependency posture (scripts/check-no-deps.sh) is unchanged: this adds code, not crates.

§Why it is a subcommand and not a script

A .ps1 for Windows plus a Makefile for Unix would be two implementations of that guard, in two languages, one of them untested — for a routine whose failure mode is deleting your work. And make is not the Unix-only detail it looks like: Git for Windows ships bash, sh and coreutils but NOT make, so the dependency was the problem rather than the shell.

The shim text is embedded with include_str!, so an installed binary carries its own shims and can install from any directory.

Re-exports§

pub use crate::hookfile::is_our_shim;
pub use crate::hookfile::SHIM_MARKER;

Structs§

Written
One dispatcher that landed, and what stood at that path before it.

Enums§

RepoHooks
Where git dispatches hooks from, and whether that is this repository’s OWN hooks directory or somewhere core.hooksPath sent it.
ShimWriteError
Why a set of shims was not written.
TemplateDir
What may be done with a candidate template directory.

Constants§

DISPATCHERS
The hook names git actually invokes, and so the only files we install.
PLACEHOLDER
The token every shim carries until it is baked.
SHIM
The one shim. All four git-invoked hooks are the same file — it passes its own filename through — and shims_on_disk_match_the_embedded_one keeps the repository’s templates/hooks/ honest against this copy.

Functions§

bake
Write the absolute binary path into a shim.
bin_dir
~/.local/bin, or $AMONT_BIN_DIR.
classify_dir
Decide what may be done with dir. Never mutates anything.
holds_our_shims
Whether any of our four shims sits in dir.
init
amont init — wire up THIS repository, and touch nothing else.
is_bakeable
Whether the shim will accept bin as its baked path.
redirect_culprit
Name the tool behind a core.hooksPath, when the path gives it away.
redirect_is_hostile
Whether a redirect must be REFUSED rather than followed.
redirected_message
The refusal both install and init give when another tool owns dispatch.
repo_hooks
Ask git both questions at once — what it dispatches from, and what this repository’s own hooks directory is — then compare.
run
Install: copy this binary somewhere stable, populate the template directory if that is safe, and bake the current repository’s hooks.
template_hooks_dir
$XDG_CONFIG_HOME/git/git-templates/templates/hooks.
uninstall
Take the shims out of the repository we are standing in.