-
-
Notifications
You must be signed in to change notification settings - Fork 412
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
lint-staged shows a different set of files to be committed than actually gets committed, and is not stashing changes before hand #1346
Comments
I see that the debug output runs this:
It claims that it stashed things. Is that step silently failing to work, with a false-positive message? |
I also have modifications in git submodules. Could that have to do with it? I know that git submodule changes cannot be stashed in the parent. I've updated the repro to include a step to modify a git submodule. |
I can't figure out what the issue is with lint-staged, but for now I was able to work around it in a less ideal way like so: First, change const buildSteps = ['npm run build', 'git add dist']
export default {
'./src/**/*': () => buildSteps,
'./packages/**/*': () => buildSteps,
} Then change #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# If a previous commit attempt's stash still exists, notify, and exit.
(git stash list | grep COMMIT_HOOK_STASH) && echo "A previous git stash named "COMMIT_HOOK_STASH" exists. Please handle and remove the stash then try again." && exit 1
git reset dist
git checkout dist
git stash save -k COMMIT_HOOK_STASH
npx lint-staged Then install #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# unstash only if there was a stash
(git stash list | grep COMMIT_HOOK_STASH) && git stash pop This basically does what I was trying to do with lint-staged, but it is not as ideal as it would be with lint-staged because:
|
Lint-staged uses With this in mind, does it make more sense? |
And it also does not appear to stash things before doing anything.
Description
I have this in
husky
pre-commit
:Here's lintstagedrc:
What I'm trying to do is add build outputs if
src/
files changed.Steps to reproduce
The repo is here: https://github.com/lume/lume, in the
develop
branch. See.lintstagedrc.js
Now, inspect the diff for the commit, and it will also contained modified
dist/
files, including files corresponding to allsrc/
files that were modified, not just the one that was committed.If I have this in my working dir:
then when
npx lint-staged
runs, it tells me the same thing when I edit the commit message (as if it will commit onlysrc
but notdist
.However, when I go inspect the commit itself, I see the equivalent of having committed this:
This indicates that
dist/
is being added, just as I've specified in mybuildSteps
.However, we see that it includes
dist/behaviors/PropReceiver.js.map
.But if lint-staged is supposed to be stashing things first, then that output file should not exist because
src/behaviors/PropReceiver.ts
would have been stashed, thereforenpm run build
will not modify that file indist/
.I can verify that if I stash changes manually myself, then run
npm run build
, no changes happen toPropReceiver.*
inside ofdist/
, as expected, so this indicates that lint-staged is running mybuildSteps
with the unstaged files in place.Debug Logs
expand to view
Environment
lint-staged
: 14.0.1The text was updated successfully, but these errors were encountered: