[question] How to get staged files parameter?
See original GitHub issuesearch tried in the issue tracker
yes
describe your issue
First, thank you for making such a useful framework.
I currently use custom hooks to run prettier
and eslint
. The reason why I didn’t use the supported hooks is that I already have commands for them, and didn’t want to rely on supported hooks.
When custom hooks are used, I cannot find a way to get staged files parameter in .pre-commit-config.yaml.
Are there any ways to do that?
pre-commit --version
2.20.0
.pre-commit-config.yaml
pos:
- repo: local
hooks:
- id: js-lint-check
name: JS Lint
entry: bash -c 'make check-eslint check-prettier'
language: system
files: 'webui/react/src/'
types_or: [javascript, jsx, ts, tsx]
pass_filenames: false
check-eslint
runs eslint **/.{js,ts,tsx,jsx} and check-prettier
runs prettier --check **/.{js,ts,tsx,jsx}
However, I wanna run commands only for staged files instead of entire project directory
~/.cache/pre-commit/pre-commit.log (if present)
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to git show a staged file?
Use git show :path/to/some/file . Files that are "staged" represent an index copy of the file that differs from some other copy, ...
Read more >Querying Data in Staged Files
Query Syntax and Parameters¶. Query staged data files using a SELECT statement with the following syntax: SELECT [ ...
Read more >2.2 Git Basics - Recording Changes to the Repository
Staging Modified Files · Let's change a file that was already tracked. · The CONTRIBUTING.md file appears under a section named “Changes not...
Read more >lint-staged
This project contains a script that will run arbitrary shell tasks with a list of staged files as an argument, filtered by a...
Read more >Git Reset | Atlassian Git Tutorial
The -s option displays additional metadata for the files in the Staging Index. This metadata is the staged contents' mode bits, object name,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
every supported hook ~usually runs with
pass_filenames: true
(because that’s the default) so you can look at the multitudes of examples thereAh I missed that. When I ran the
pre-commit run --all-files
, I got errors, so I put it to make it silent. Could you please give me an example to get filenames to commands whenpass_filenames: true
?