Run hooks on files in specific dir, rather than using `--all-files`

See original GitHub issue

I am able to successfully use pre-commit run --all-files to run hooks on all my files.

Now, I’m trying to run the hooks just on files in a particular directory. I think I’m not understanding the docs and I can’t find an example to work from.

Here’s what the docs say:

--files [FILES [FILES ...]]: specific filenames to run hooks on.

I’ve tried the following variations: pre-commit run --files web/modules/custom pre-commit run --files web/modules/custom/* pre-commit run --files [web/modules/custom] pre-commit run --files [web/modules/custom/*] pre-commit run --files [FILES [web/modules/custom] pre-commit run --files [FILES [web/modules/custom/*]

I feel really dumb having to ask, but can someone please point me in the right direction?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:28 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Oct 19, 2019

I’m going to normalize paths to forward slashes in #1179 – this should make this less painful on windows (simpler regexes, and it’ll fix that bash script that’s not-quite-right 😄)

1reaction
asottilecommented, Oct 15, 2019

that’s positively puzzling! I’ll have to dig into this some more and see if I can’t craft a repository which reproduces this 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git pre-commit hooks only for a specific subfolder?
I want to have a pre-commit hook that will run jshint but only if any of the staged files are in the Javascript...
Read more >
Execute git pre-commit hook only if files in certain directory ...
You can use the git builtin git diff --cached --quiet -- "$SRC_PATTERN" . --quiet implies --exit-code , which makes git exit with code...
Read more >
What's a good way to have a hook that runs for every file in a ...
find-file-hook , and in your hook function, check whether the candidate file is in the given directory.
Read more >
pre-commit
To run individual hooks use pre-commit run <hook_id> . The first time pre-commit runs on a file it will automatically download, install, and...
Read more >
How to use git pre-commit hooks, the hard way and the easy ...
git/ directory, open up the .git/hooks/ directory. You will see a bunch of files named hook-type.sample . You should see one named pre ......
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