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
Support working-directory
options for hooks
#429
Comments
Thanks @TNonet. Indeed, this repo layout does not work with the hook {precommit} provides. Pre-commit uses command line arguments to specify hook behaviour. Hence that's the natural solution I think. We could just pass a |
Hi @lorenzwalthert, Thanks for such a fast response. I would be happy to make a PR. After a quick scan of the logic, I would plan to add a A few other comments/questions:
|
Because the file names are passed to the hook as relative paths, you may need to convert them to absolute paths (with base R preferably) before setting the working directory.
I don’t think so. regarding tests, that’s a bit of a tricky one. Testing infra has grown organically to cover all use cases and os a bit of a mile field 😜. I think I can set it up for the root argument next week. Also, I wonder if we should add the argument to all hooks, no matter if it has an effect or not. Just for completeness. |
Hi @lorenzwalthert, Thanks for the example. I will see what I can do. |
It seems that adding docopt to I added the following lines to
And I received the following unexpected failure.
I have yet to make my way through the internal logic of the testing, but I wanted to raise this issue just in case it jumps out at you. |
Ok, it was related to an error message that now has an absolute path. Fixed and re-based on main for a cleaner diff... All passing. |
Hi @lorenzwalthert, Sorry for the delay on this. I had covid for a few weeks. I still see this error below when running tests on both #432 and main. However, the code seems to run correctly when executing the R hook script on packages:
|
oh no, sorry to hear that. Hope everything is ok now… All CI passes, so I don’t know what’s the problem is on your side. Maybe update all your R packages? |
Is your feature request related to a problem? Please describe.
I would like a way to run many of these pre-commit hooks in arbitrary subdirectories.
I am creating a repository with the following layout:
Currently,
use-tidy-description
,deps-in-desc
, and a few other hooks will fail with this repo layout.Describe the solution you'd like
Each pre-commit hook (if possible) has either a
before
script that can allow users to change directories or support some type of argument for specifying theworking-directory
similar to github actions.Describe alternatives you've considered
An alternative approach would be to support
.pre-commit-config.yaml
files in subdirectories but that seems out of scope for this project.The text was updated successfully, but these errors were encountered: