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

pre-commit hook affects staging of partially staged files #62

Closed
MattijsKneppers opened this issue Jun 22, 2018 · 11 comments
Closed

pre-commit hook affects staging of partially staged files #62

MattijsKneppers opened this issue Jun 22, 2018 · 11 comments

Comments

@MattijsKneppers
Copy link

When pre-commit is enabled in package.json, if files are partially staged in git, all file changes are moved to staged instead.

Explanatory screen grab here (unlisted):
https://youtu.be/U2G7Sso9geU

The issue also stands when using the git CLI.

@ThaNarie
Copy link

I read the same thing in their docs this week:
https://prettier.io/docs/en/precommit.html
lint-staged/lint-staged#62

https://github.com/nrwl/precise-commits#why-precise-commits
this would be an option (from their docs), but haven't looked into it yet, so might miss some features that we now have.

@ThaNarie
Copy link

Workaround:

  • run prettier command
  • run lint commands
  • if everything passes, commit with --no-verify (or uncheck 'commit hooks' in webstorm)

@MattijsKneppers
Copy link
Author

Happy to know I'm not alone, thanks for the workaround :)

@ThaNarie
Copy link

Adding some info after reading in; it's a hard problem to properly fix.

After running prettier or eslint --fix, you would need to add those changes. Since the tool can only re-add the complete file, the other tools solve this by first stashing un-added changes.

The problem then is that the stashed changes can conflict with the reformatted files in the working copy when unstashing them. If we're fine with that, we could add a git stash -k and git stash pop around the prettier/git add commands.

@hjeti
Copy link
Owner

hjeti commented Sep 19, 2018

Let's ignore this for now. Just keep in mind that you cannot commit partially staged files.

@hjeti hjeti closed this as completed Sep 19, 2018
@MattijsKneppers
Copy link
Author

I keep having serious issues with this, committing partially is an essential element of my workflow that works well for all other projects I work on. I would personally instead choose for disabling the pre-commit hook entirely until this can be fixed.

@hjeti
Copy link
Owner

hjeti commented Oct 2, 2018

@MattijsKneppers I think you are the only one with a workflow like that. Nobody did a thumb up or reported the same issue. Disabling the hook is not really an option we want formatted and code according to the coding standard in the repo. Using the workaround from Narie has drawbacks with conflicts. So I don't really see a way to fix this for your workflow.

@MattijsKneppers
Copy link
Author

@hjeti True, if I'm the only one using partially staged files I can imagine this is not a priority.

@hjeti
Copy link
Owner

hjeti commented Nov 14, 2018

@MattijsKneppers Lint staged supports partially staged files in version 8.0.0. I've updated all dependencies to the latest version so the latest version of vue skeleton should have support for your workflow. I didn't test it but you can test it now in the latest version of vue-skeleton (v1.7.1).

lint-staged/lint-staged#75

@MattijsKneppers
Copy link
Author

@hjeti great news, thanks for chasing this! This is going to make my life and that of the people who's code I keep messing up a lot easier :)

@MattijsKneppers
Copy link
Author

I can confirm that it is fixed now.

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