Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Implement quiet mode, silent on skipped hooks (WIP) #1560
Conversation
|
fwiw the namespace for git hooks is constructed inside hook-impl: pre-commit/pre_commit/commands/hook_impl.py Lines 67 to 93 in 4f5cb99 |
|
Thank you for the namespace pointer - that fixed my exception. I think the next step is to add
to:
And finally from a configuration point of view, update (That still leaves the desired behaviour of quiet mode to be refined) |
|
Any preference on the command line help listing I ask since currently the existing command lines are not 100% consistent here, something perhaps worth addressing separately? |
Thank you to Anthony Sottile for guidance here.
Can now add --quiet to the scripts like .git/hooks/pre-commit to run in quiet mode.
Downside is delay output on failed hooks
Adding a new summary line if all hooks passed or were skipped in either --quiet mode (where it may be the only output) or --verbose mode (since the summary seems worth showing here).
|
The tests are failing during Tox, lots of |
|
I believe the next key to the puzzle is testing.util.run_opts |
This reverts commit 5c1a749. Feedback from Anthony Sottile was to focus on the skipped messages only for now.
e.g. $ SKIP=mypy pre-commit run --files pre_commit/*.py Trim Trailing Whitespace.................................................Passed Fix End of Files.........................................................Passed Check docstring is first.................................................Passed Check JSON...........................................(no files to check)Skipped Check Yaml...........................................(no files to check)Skipped Debug Statements (Python)................................................Passed Tests should end in _test.py.........................(no files to check)Skipped Fix requirements.txt.................................(no files to check)Skipped Fix double quoted strings................................................Passed flake8...................................................................Passed autopep8.................................................................Passed Validate Pre-Commit Manifest.........................(no files to check)Skipped pyupgrade................................................................Passed Reorder python imports...................................................Passed Add trailing commas......................................................Passed setup-cfg-fmt........................................(no files to check)Skipped mypy....................................................................Skipped Check hooks apply to the repository..................(no files to check)Skipped Check for useless excludes...........................(no files to check)Skipped Versus: $ SKIP=mypy pre-commit run --files pre_commit/*.py -q Trim Trailing Whitespace.................................................Passed Fix End of Files.........................................................Passed Check docstring is first.................................................Passed Debug Statements (Python)................................................Passed Fix double quoted strings................................................Passed flake8...................................................................Passed autopep8.................................................................Passed pyupgrade................................................................Passed Reorder python imports...................................................Passed Add trailing commas......................................................Passed mypy....................................................................Skipped Here we still show mypy which the user had said to skip.
Placed next to verbose due to logical connection. This is not part of a public API so the change should not matter - the tests all seem to pass arguments by name anyway.
|
Modified as per comments. Some tests still failing (likely due to my addition of a one line summary in verbose mode). If we are going to leave the passed lines, then the one line summary to prevent a silent run is only really needed if all the hooks were silent passes. Are you open to adding another return value to |
I would like to see pre-commit be less verbose, issue #823.
Version 3
Based on feedback this no longer alters the "Passed" lines at all, only "Skipped" lines are silenced in the new
--quietmode, and only when there were no files to check (not silenced if skipped via configuration).The core functionality seems to be working, the test suite needs updating still.
Example:
versus:
Version 2
I would like to see pre-commit be less verbose, issue #823. The core functionality seems to be working, the test suite needs updating still.
I looked at #1218, but here I am trying to be less invasive. The idea here is in quiet mode never print the skipped or passed lines. Attempting to silence the "Passed" lines is more complicated since the initial part is normally printed before we know if it will pass or fail. This takes the pragmatic approach in quiet mode of not even printing the hook name until we know it failed.
As per discussion on #823, success is not silent - a one line summary is shown instead. This could report the number passed vs skipped but would need minor changes to the
_run_single_hookfunction.Example:
versus:
Typical usage would be
pre-commit install --quietwhich will write the.git/hooks/pre-commitscript with the--quietargument included, ready to be triggered viagit commit ...as usual.Version 1 - Original description
I would like to see pre-commit be less verbose, issue #823. This is a work in progress, since I got stuck - but shared for comment/feedback.
I looked at #1218, but here I am trying to be less invasive. The idea here is in quiet mode never print the skipped lines. Attempting to silence the "Passed" lines would be more complicated since the initial part is printed before we know if it will pass or fail.
This works:
versus with
-qor--quiet:However, when called via git the git pre-commit hook, I'm missing something with the arg setup:
The log file says:
I am puzzled why "args.verbose" works, but "args.quiet" fails since both are defined in the same place.
(As an aside,
--verboseand--quietcould be setup as mutually exclusive)I have not yet attempted to set quiet mode at install time (which is how I would likely use it myself).