Skip to main content

Module install

Module install 

Source
Expand description

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

Everything this module prints is a report for a person (what was installed, wired, trusted or left alone), so all of it goes to stderr, in one stream and in order; stdout stays free for data.

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§

Installed
Whether our shims are in a hooks directory, and the binary each bakes.
Written
One dispatcher that landed, and what stood at that path before it.

Enums§

InstalledState
How much of amont is in a hooks directory.
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.
enroll
amont enroll — the machine-level standing grant, made one command.
forget_bookkeeping_in
Everything this tool ever wrote into ONE repository, forgotten — the single list, so the two uninstall paths cannot drift apart.
holds_our_shims
Whether any of our four shims sits in dir.
init
amont init — wire up THIS repository, and touch nothing else.
installed_here
The repository’s hooks, where git dispatches from.
installed_in
Read the shims in dir from the files themselves, never from the list of checks: what is installed is what is on disk.
installed_in_template_dir
The machine’s template dir, which every git clone copies hooks from.
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.
repo_hooks_in
repo_hooks for the repository at dir, so a test can aim it at a fixture without moving the process.
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.
uninstall_repo
amont uninstall --repo: this repository’s shims and bookkeeping, and nothing else. The template dir, init.templateDir and the binary are machine state, which an installer that armed one repository must leave exactly as it found them.