Skip to content
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

Check just the staged content of the changed files #117

Open
georgiyordanov opened this issue Dec 10, 2020 · 2 comments
Open

Check just the staged content of the changed files #117

georgiyordanov opened this issue Dec 10, 2020 · 2 comments

Comments

@georgiyordanov
Copy link

Hi,

I'm using pretty-quick to just check the contents of the commit in a precommit hook and fail if there are any issues without formatting/staging anything. It works well and fast, but my problem is it checks the contents of the file as it exists in the filesystem. If I have some staged changes that are not formatted correctly, but also have the file formatted correctly as unstaged, the check succeeds as it reads the file from the filesystem, thus allowing to create a commit that will not pass validation on the CI.

@max-kahnt-keylight
Copy link

max-kahnt-keylight commented Mar 13, 2021

I have the opposite behavior: Valid staged changes are not accepted since apparently the working directory is checked instead of the index.

To summarize: I think the "--staged"-flag doesn't work currently and creates both, false-positives and false-negatives.

Edit: My false-negatives seem to be an issue with partial staging only. Ping me in case you need further details. Maybe only the documentation needs an update on how it interacts with partially staged files (or I repeatedly read it wrong).

If there is no intent to just format the staged content, I think it would help to be more explicit in the documentation (README.md) about partially staged files treatment. Now that I actually understood what is happening, I can see that this is described. But I also believe that my prior confusion is not unjustified.

@JounQin
Copy link
Member

JounQin commented Jan 16, 2024

I think this complex usage case is not suitable for this package, maybe you can try https://github.com/lint-staged/lint-staged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants