Skip to content

Commit c19079d

Browse files
committed
fix: try to restore hidden unstaged changes when using --no-revert
1 parent 68b8299 commit c19079d

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎.changeset/empty-rules-exist.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'lint-staged': patch
3+
---
4+
5+
Try to restore hidden unstaged changes when using `--no-revert`.

‎lib/state.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const restoreUnstagedChangesSkipped = (ctx) => {
7575
// we can still restore unstaged changes to make it easier
7676
// to do manually.
7777
if (!ctx.shouldRevert) {
78-
false
78+
return false
7979
}
8080

8181
// Should be skipped when tasks fail

‎test/e2e/no-stash.test.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('lint-staged', () => {
4141
)
4242

4343
test(
44-
"--no-stash doesn't imply --no-hide-partially-staged, losing conflicting unstaged changes",
44+
"--no-stash doesn't imply --no-hide-partially-staged",
4545
withGitIntegration(async ({ execGit, expect, readFile, writeFile, cwd }) => {
4646
await writeFile('.lintstagedrc.json', JSON.stringify(configFixtures.oxfmtListDifferent))
4747

@@ -58,7 +58,7 @@ describe('lint-staged', () => {
5858
)
5959

6060
// unstaged changes were discarded
61-
expect(await readFile('test.js')).toEqual(fileFixtures.uglyJS)
61+
expect(await readFile('test.js')).toEqual(fileFixtures.uglyJSWithChanges)
6262

6363
expect(await execGit(['status'])).toMatch('new file: test.js')
6464
})

0 commit comments

Comments
 (0)