-
-
Notifications
You must be signed in to change notification settings - Fork 51
What happens under the hood when I install the hooks?
Lorenz Walthert edited this page Jul 29, 2023
·
1 revision
What pre-commit install --install-hooks does:
- clone lorenzwalthert/precommit into its cache and give it a name starting with
repo.... On macOS, thatrepo...lives in~/.cache/pre-commit/. - Then, it places an installation script in that repo.
- Then, it runs that script with the working directory being where the script is located, roughly it runs
renv::restore(). - As part of running the installation script, it also writes an activation script, that will be executed from your project's working directly, which roughly is 1) change working directory to
repo..., 2)renv::load()(which is similar torenv::activate()) and 3) change back to your projects working directory.
When you then run a hook, it sets that activate script as your .Rprofile through an environment variable and executes the hook scripts.