lint-staged: When a watcher process being used, git stash restoration might fail
I’ve been testing beta-6
and noticed that if there is a watcher process that modifies files is being used, lint-staged will fail ungracefully:
M src/components/primitives/Text/Text.js
MM src/exercises/3-Primitives/Text.js
M src/exercises/3-Primitives/final/Text.js
MM src/exercises/3-Primitives/templates/Text.js
component-driven-development on rerere2 [⇡$!+] is 📦 v0.1.0 via ⬢ v10.15.3
➜ gc
husky > pre-commit (node v10.15.3)
✔ Preparing...
✔ Running tasks...
✖ Applying modifications...
→ Unstaged changes could not be restored due to a merge conflict!
Cleaning up...
Unstaged changes could not be restored due to a merge conflict!
husky > pre-commit hook failed (add --no-verify to bypass)
component-driven-development on rerere2 [⇡=$+] is 📦 v0.1.0 via ⬢ v10.15.3 took 2s
➜ g st
## rerere2...origin/rerere2 [ahead 2]
M src/components/primitives/Text/Text.js
M src/exercises/3-Primitives/Text.js
UU src/exercises/3-Primitives/final/Text.js
M src/exercises/3-Primitives/templates/Text.js
Notice how after the fail my index looks very differently having staged files that weren’t staged before the commit attempt. Ultimately, the new index is exactly the changes I didn’t want to commit in the first attempt.
Also the error message isn’t helpful in resolving the situation.
Steps to repro:
- Checkout https://github.com/component-driven/component-driven-development
- Run
npm run generate:watch
- Edit
src/exercises/3-Primitives/templates/Text.js
and see howsrc/exercises/3-Primitives/final/Text.js
and being updated. - Add those changes to the index by
git add .
- Try to commit
I realize this is might look like a rare scenario at first, but I believe most of issues with lint-staged staging algorithm came from webpack (or other tools) users running it in watch mode in parallel.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 28 (15 by maintainers)
A new untracked, unstaged file would still be in the original backup stash (
--include-untracked
setting) and thus get restored when applying the stash back after running tasks.