question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Default install arguments on `.pre-commit-config.yaml`, because `--hook-type`s again

See original GitHub issue

Hi, @asottile! šŸ‘‹ šŸ˜Š

I was writing https://github.com/conventional-changelog/commitlint/pull/2715, and I ended up having trouble trying to communicate to the use how to use pre-commit install.

I understand this has been addressed multiple times on https://github.com/pre-commit/pre-commit/pull/1145, and I only skimmed the linked duplicates, but I wonder if youā€™d be open to another approach. Namely, to define the install args on .pre-commit-config.yaml, maybe under some new key, and also maybe adding a new command (like auto-install?).

This is not the most elegant solution, but it lessens the pain on people with non-trivial setups, and letā€™s them say ā€œjust pre-commit auto-install, no excusesā€ to their team mates.

Thanks for entertaining my idea!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pkochcommented, Aug 20, 2021

I imagine pre-commit install -t commit-msg isnā€™t that bad ?

In my case, itā€™d be pre-commit install -t commit-msg -t commit, and this would be even worse for people with more elaborate setups.


I think this ends up being a product decision. Iā€™m of the opinion that pre-commit should aim to be setup with just pre-commit install.

From what I can read on https://pre-commit.com, its central promise is it ā€œjust workingā€ and people not having to worry to setup their own virtualenvs (or cash equivalent in other langs) and put the right symlinks in the right place.

You specify a list of hooks you want and pre-commit manages the installation and execution of any hook written in any language before every commit.

By skipping this hook types bit, weā€™re effectively pushing that that installation responsibility problem back to the user. I now have to ā€œcopy and paste bash scripts from project to projectā€ again, even if theyā€™re small. Telling people to ā€œjust type itā€ is putting the install script in another place (prolly the projectā€™s README or, even worse, in their heads).

Including this last mile clearly (to me) brings users value.


Now, Iā€™m not insensible to the growth pains that seem very obvious from hook types. My solution proposal is indeed a big hammer (which could be boon for some other future problems, but clearly feels like a hack nonetheless). Maybe the right call is to wait for the next breaking change and make default_hook_types be only [commit]? Maybe something else?

0reactions
asottilecommented, Aug 20, 2021

Iā€™m going to continue to defer for now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto-Install different hook types Ā· Issue #1338 - GitHub
The pre-commit install command should (maybe via use of an --auto flag?) detect all of the defined hook types in the .pre-commit-config.yaml ......
Read more >
pre-commit
The pre-commit config file describes what repositories and hooks are installed. .pre-commit-config.yaml - top level Ā¶. new in 1.0.0: The default configurationĀ ...
Read more >
pre-commit hooks | Documentation - Poetry
pre-commit-config.yaml , the defaults are overwritten. You must fully specify all arguments for your hook if you make use of args: .
Read more >
Automating Python Workflows with pre-commit Hooks
Finally, we need to install the hooks from the file. The following command will automatically parse the content of .pre-commit-config.yaml ...
Read more >
How to configure pre-commit-config.yaml to work with poetry?
the point of pre-commit is it installs and manages your tools -- that way you don't have to have your contributors worry about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found