Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add quiet mode to pre-commit run #1218

Closed
wants to merge 2 commits into from

Conversation

allburov
Copy link

@allburov allburov commented Nov 12, 2019

Add --quiet flag ot pre-commit run to show only failing hook's messages.

Fix #823

TODO:

  • Add --quiet flag to pre-commit run
  • Introduce env variable PRE_COMMIT_QUIET=0|1|false|true which allow users to enable quiet mode by default in their PC
  • Add option --output-mode=[normal|quiet] to pre-commit install command
  • Add docs about flag and option to https://github.com/pre-commit/pre-commit.github.io

@allburov
Copy link
Author

@asottile what about this to fix #823? Could you review this solution, please.

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first off, thanks for working on this

I don't think I can accept this in its current state, there's a ton of complexity added in this patch (for a feature I'll never really use) that I'm not comfortable with. Also the use of inheritance when a function would do seems not a good idea

let me know if you'd like a more in depth review but I think this feature might just be too complex to implement (and especially in one go)

@allburov
Copy link
Author

@asottile
I understand your opinion, very few repositories have more than 10 hooks (I have looked to open source repositories). But a big project (without shared code base) may have a lot of hooks. However it's really less than 1% of repositories who use pre-commit.

I tried write this with if-statements, but it looked hard.
I tried rewrite with "pass args.quiet" to functions (like args.color is passed) - it did not seem pythonic and easy to read or modify.
I looked at logging or ansible.display solutions also, but it also will have if statement to print the first status message with number of hooks.

So my decision is just inject new output to run hook function. If you will want to write new string to console in the function you just will use write_line or write and don't wary about quiet mode.

Lets going to simplify the solution (if we will can without increase complexity)!

@blueyed
Copy link

blueyed commented Nov 22, 2019

@allburov
Maybe wrapping the whole output / run is more feasible in the long run? 77aab5e

@peterjc
Copy link

peterjc commented Aug 16, 2020

I tried the other extreme in #1560, no output wrapping at all - just suppressing "skipped" message output in the first place. This seemed like the low hanging fruit, and made me wonder about having that off by default - thus #1561 which only shows the "skipped" messages in verbose mode.

@asottile asottile closed this Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Quiet mode (pre-commit install --quiet) which outputs less while running
4 participants