question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] How to get staged files parameter?

See original GitHub issue

search 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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Sep 29, 2022

every supported hook ~usually runs with pass_filenames: true (because that’s the default) so you can look at the multitudes of examples there

0reactions
Gumichocopengin8commented, Sep 29, 2022

Ah 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 when pass_filenames: true?

Read more comments on GitHub >

github_iconTop 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 >

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