Comments (7)
Let me try and make a grid, but in list form of the possible commands / situations:
pre-commit install
- ✔️ installs
.git/hooks/pre-commit
- ✔️ keeps non-pre-commit hooks around (
.git/hooks/pre-commit.legacy
-- migration mode) - ❌ installs hook environments
- ✔️ idempotent
- ✔️ installs
pre-commit install-hooks
- ❌ installs
.git/hooks/pre-commit
- ❌ keeps non-pre-commit hooks around (
.git/hooks/pre-commit.legacy
-- migration mode) - ✔️ installs hook environments
- ✔️ idempotent
- ❌ installs
pre-commit install --install-hooks
- ✔️ installs
.git/hooks/pre-commit
- ✔️ keeps non-pre-commit hooks around (
.git/hooks/pre-commit.legacy
-- migration mode) - ✔️ installs hook environments
- ✔️ idempotent
- ✔️ installs
pre-commit install --install-hooks --force
- ✔️ installs
.git/hooks/pre-commit
- ❌ keeps non-pre-commit hooks around (
.git/hooks/pre-commit.legacy
-- migration mode) - ✔️ installs hook environments
- ✔️ idempotent
- ✔️ installs
Basically, the only time you'd care about --install-hooks
is if you want to eagerly install the hook environments before running -- it won't really make a difference but can help improve the perception that "pre-commit is slow" by frontloading the one-time install.
--force
isn't really a necessary option unless you were previously using some other git hooks framework and want to no longer use that framework. ~technically all of the operations are idempotent but in the case of --force
it's called out explicitly (similar to the way that rm -f
and mkdir -p
are idempotent)
The reason the full command is shown is that was the most common invocation at yelp where they were migrating from a 2k line bash-based git hooks framework and wanted make minimal
to eagerly install the hook environments
from pre-commit.com.
The bit that always confuses me about this is I think of .git/hooks/pre-commit
as a hook
so my mind assumes install-hooks
is creating that. It all makes sense once you realize hooks
here means the venvs for the linters etc.
I get how it's rooted in the origins of pre-commit and it's probably too late to change. But calling the things it runs tools instead of hooks might've made some things clearer.
from pre-commit.com.
I don't think it's necessary at all, each of the options are independent and already documented -- if there's clarification needed for the individual options I'd suggest augmenting those
from pre-commit.com.
Thank you! That's very clear and helpful.
If it would help integrate that into the docs, I could built out a markdown table or such, or just send a PR if you would accept it.
from pre-commit.com.
Where do the hook environments get installed?
from pre-commit.com.
that's implementation detail -- but ${PRE_COMMIT_HOME:-${XDG_CACHE_HOME:-~/.cache}/pre-commit}/...
from pre-commit.com.
Cool, thanks. Yeah, don't intend to document this explicitly, just testing some behavior to make sure I get a couple things right.
from pre-commit.com.
Related Issues (20)
- Supported hooks page not listing language C++ HOT 2
- Add sorting options to https://pre-commit.com/hooks HOT 9
- Add a license? HOT 6
- Is install-local.py deprecated? HOT 1
- Language change in hook repo not picked up in index of supported hooks HOT 3
- Gitlab cache configuration (as documented) leads to corrupted/invalid cache HOT 6
- Add official shellcheck hook HOT 2
- (📚) pre-commit-config section doesn't mention the `ci` key HOT 1
- document pre-commit in a merge-request pipeline HOT 1
- Link to `default_install_hook_types` is not correct HOT 4
- Documentation assumes incorrectly that a tag is an immutable ref - leading to a supply-chain security risk HOT 1
- Add sql-formatter hook HOT 2
- Add `Rome` formatter as a mirror. HOT 2
- It’s not clear which languages can’t be used for local hooks HOT 3
- Version in docs is out of date HOT 1
- pre-commit ci incorrectly reports an error with the walrus operator (python 3.11) HOT 2
- License still necessary
- Ambiguous documentation HOT 1
- `pretty-format-json` timeout error HOT 3
- Filter hooks by language HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pre-commit.com.