Open ghost opened 5 years ago
Yeah, as you said, currently tests are run against the local files. I think we should push stash the current changes and checkout the commit before running tests (and pop the stash finally) in a generated script.
https://github.com/rhysd/cargo-husky/blob/master/build.rs#L104
A simple step forward might be a hook that fails if there are staged changes when you're trying to push. - that'd definitely catching things I meant to push but forgot to commit.
I presume this same bug applies to the pre-push script?
The pre-commit hook generated by this crate run on whatever files are on disk at the moment including on content that has not been commited and is not included in this commit. It creates false-positives and false-negatives.
Everything that is not in the stagging area should probably be stashed before running the hooks.
This is probably best described in this article https://dzone.com/articles/why-your-need-git-pre-commit
Thank you for sharing this work by the way, even with this small issue, it is still a great tool to have.