precise-commits: Modifications not being commited
Hi! I just discovered the project and it is exactly what I was looking for đ I am coming from lint-staged and I was looking for this extra precision đ
I just did my first attempt to use it within the precommit hook. I staged some unformatted files and then committed them.
- What I expected: to get the staged files first formatted and then committed.
- What happened: I got the staged files committed, then they got formatted and this modifications remained as unstaged.
I guess my expectations are the intended way to work, right?
Iâm using precise-commits 1.0.0 and husky 0.14.3
Please let me know if you need some extra info or clarifications.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 11
- Comments: 20 (4 by maintainers)
Why even use a precommit hook when the resulting commit is not affected in any way? This is counter-intuitive.
As for me, I would appreciate an auto-commit flag as well. Thanks for your work!
Hi @CarlosGines, thanks for raising!
Currently your expectation from
lint-stagedis not the wayprecise-commitsis set up to work. We are still discussing the optimal workflow when it comes to applying the formatting to git. Some feel quite strongly that the logic and version control should be separate, as sometimes âmagicâ commits happening behind the scenes can be undesirable.We may end up adding a flag for the auto-commit behaviour, I will update this issue with progress.
@drazik, cool, this seems to be working as desired:
For those who came here because lint-staged didnât handle partially staged files, itâs does it now: https://hackernoon.com/announcing-lint-staged-with-support-for-partially-staged-files-abc24a40d3ff
This is what would work for me:
check-onlyflag, which will not perform the formatting changes at all.In the meantime, I will have to change to a different tool, but Iâd rather use this one.
To prevent âmagicâ commits, an auto stage flag would also be a nice option. So it would be easier to commit the prettified changes in a next commit.
for future googler : see here https://github.com/nrwl/precise-commits/issues/20#issuecomment-621110837
So, are people always committing twice? Just trying to understand the recommended workflow. Seems like it would be undesirable to always have two commits for each⌠commit.
âAdd Foo to Barâ âPrettier cleanupâ
âAdd Bar to Bazâ âPrettier cleanupâ
You could, of course, use a vscode prettier extension but then whatâs the point of this library?
in the package.json scripts
this will do what you guys are wanting i think
@vicb is working on this for angular/angular