pub fn init() -> Result<(), String>Expand description
amont init — wire up THIS repository, and touch nothing else.
The verb a package manager can call. "prepare": "amont init" in a
package.json means a teammate who clones and runs npm install gets the
hooks, which is the ergonomic husky has and this project did not.
§Why install could not be that verb
Every one of its three extra steps is wrong for something that runs on every teammate’s install, and the third is a hang:
install_binarycopies into~/.local/bin— a machine-level write fromnpm install;populate_template_dirwrites~/.config/git/git-templates, so a package manager would be arranging for every FUTURE clone to get hooks;offer_trustcallstrust::confirm, which opens/dev/tty. In a terminal that succeeds and BLOCKS, sonpm installwould stop dead on a prompt about a manifest the user has not read.
So this does one thing: bake four shims into the repository’s own hooks directory.
§What it bakes, and why not the PATH hit
current_exe(), always — never [install_binary]’s “is it already on
PATH?” branch. Under npm the answer to that question is
node_modules/.bin/amont, which is the JS wrapper: baking it would put a
node process in front of every single commit, on a tool whose start-up cost
is a stated feature. current_exe() is the native binary inside the platform
package, which is what should run.
§Silence, and its limits
Outside a git repository this reports nothing and exits 0. npm install
legitimately runs where there is no .git — from a tarball, inside a Docker
build, in CI — and failing there would make the package uninstallable in all
three. It stays LOUD about everything else: a redirect, an unwritable
directory and a foreign hook all still fail, because those are repositories
where somebody believes they have hooks and does not.