-
-
Notifications
You must be signed in to change notification settings - Fork 801
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
Provide option to log all pre-commit activity #696
Comments
What sort of output are you looking for. Does Mostly looking to scope this :) |
Not sure of what would be the best format but a log file that contain the following information would be very helpful: |
@asottile Do you know of a way to configure |
@Kilo59 there currently isn't a way, though you can set |
@asottile do you have any suggestions for how I might get started adding this feature? Love the project btw. |
Which feature? OP's feature or "verbose during git commit"? |
Sorry, should have been more clear. The "verbose during git commit". |
ok! Let's discuss the ergonomics of such a feature and the possible approaches for that -- I'll give you code hints for each of them :)
This would follow the precedent set by You'd get output something like this: $ PRE_COMMIT_VERBOSE=1 git commit -m 'test'
[trailing-whitespace] Trim Trailing Whitespace...........................Passed
hookid: trailing-whitespace
output if it had some
[master (root-commit) ba90d2e] test
1 file changed, 5 insertions(+)
create mode 100644 .pre-commit-config.yaml
$ git commit -m "test"
Trim Trailing Whitespace...........................Passed
[master (root-commit) ba90d2e] test
1 file changed, 5 insertions(+)
create mode 100644 .pre-commit-config.yaml This would probably be done by changing the default for You'd write a test for this behaviour here (I've highlighted a similar test that you could adjust) This to me feels like the nicest behaviour,
This would look something like: verbose: true
hooks:
# ... To add to the configuration schema, you'd add a property here (I've highlighted a similar property). You would then update the behaviour of You'd probably add a test here (I've highlighted a similar test which sets This has the one downside that if one of your consumers doesn't want the verbose behaviour they don't really have a way to turn it off.
$ pre-commit install --use-verbose
$ git commit -m '...'
(verbose output Something about this irks me but I can't quite put my finger on it, perhaps it's that I want the hook template to be as logic free as possible since it's really difficult to test / debug / reason about (and the end user visibility here is really poor). That said, there is precedent via You'd probably test this in the same place as option 1, though you'd probably follow this test Hope this is helpful, let me know what you think! |
Seems there hasn't been any renewed interest in this, going to close for now |
FTR it'd be great to have some verbosity level causing pre-commit output the commands that it runs, not even for fetching stuff but at least for running the check itself. |
I'd rather not expose the internals / implementation details. if pre-commit produces that output it will end up that people depend on it and muck around with the environments (already saw this happen when people were unhappy when I moved and renamed the internal repositories) |
I'm mostly talking about the entrypoint and the rendered args. |
the but note that the argument pattern is documented and without special cases |
Yes, but sometimes it feels like it doesn't really do what's documented and you really want to see some confirmation. |
so you don't trust it :P |
Sort of. It's more of I don't trust myself. It's like debug output in any other software. |
sure, then the debugging tool provided is the |
But that requires me to change the hook entry I'm testing, right? |
yes |
Then it's unusable if you want to test how some third-party hook behaves. |
how so? you need to set |
Because it's a lot of mental overhead here compared to typical |
Wait, from what I understood, the answer to
should have been "no". You don't need to change the hook, in order to use For example, if you have this repos:
- repo: <repo_url>
hooks:
- id: <hook_id>
files: >
(?x)(
.+\.m$
)
args:
- --argument
- 'value' you only need to add: - repo: meta
hooks:
- id: identity
files: >
(?x)(
.+\.m$
)
args:
- --argument
- 'value' to the end of it. I didn't test this though, but if I am correct, it means that you also don't have to
|
yep though |
I updated it. |
@asottile regarding your comment above — this was never implemented, correct? I could need this option to debug an issue where mypy run by the hook behaves differently than mypy run manually in that same terminal. I presume the two mypy runs differ either in setup or environment, but that’s hard to chase down without getting some insight into what pre-commit does when the hook runs 🤔 |
try reading the note in the readme |
I wish there were more willingness to have this added. 🙁 I'm interested in this as well.
Could the solution to this be to be explicit in the docs about what is considered an "implementation detail" vs what can be relied upon? I feel like it's very reasonable to say "the details about runtime environment locations and configs may change from release to release". Some details (in no particular order) about my use case for wanting this right now:
I wish that instead of all that I could just do EDIT: I finally just went through and executed those instructions and got the following:
😭 |
yeah for the |
btw I'd recommend https://github.com/shellcheck-py/shellcheck-py since it doesn't use docker and tends to work better and faster |
I would like to see an option to log all pre-commit activity (success, warnings, failures, errors) so that it can then be used to perform metrics against it and other uses.
The text was updated successfully, but these errors were encountered: