Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
--no-stash
flag implies --no-hide-partially-staged
- Loading branch information
Showing
10 changed files
with
110 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'lint-staged': minor | ||
--- | ||
|
||
Using the `--no-stash` flag no longer discards all unstaged changes to partially staged files, which resulted in inadvertent data loss. This fix is available with a new flag `--no-hide-partially-staged` that is automatically enabled when `--no-stash` is used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { jest } from '@jest/globals' | ||
|
||
import { withGitIntegration } from './__utils__/withGitIntegration.js' | ||
import * as fileFixtures from './__fixtures__/files.js' | ||
import * as configFixtures from './__fixtures__/configs.js' | ||
|
||
jest.setTimeout(20000) | ||
jest.retryTimes(2) | ||
|
||
describe('lint-staged', () => { | ||
test( | ||
'skips hiding unstaged changes from partially staged files with --no-hide-partially-staged', | ||
withGitIntegration(async ({ execGit, gitCommit, readFile, writeFile }) => { | ||
await writeFile('.lintstagedrc.json', JSON.stringify(configFixtures.prettierWrite)) | ||
|
||
// Stage ugly file | ||
await writeFile('test.js', fileFixtures.uglyJS) | ||
await execGit(['add', 'test.js']) | ||
|
||
// modify file with unstaged changes | ||
await writeFile('test.js', fileFixtures.uglyJSWithChanges) | ||
|
||
// Run lint-staged with --no-hide-partially-staged | ||
const stdout = await gitCommit({ lintStaged: { hidePartiallyStaged: false } }) | ||
|
||
expect(stdout).toMatch( | ||
'Skipping hiding unstaged changes from partially staged files because `--no-hide-partially-staged` was used' | ||
) | ||
|
||
// Nothing is wrong, so a new commit is created | ||
expect(await execGit(['rev-list', '--count', 'HEAD'])).toEqual('2') | ||
expect(await execGit(['log', '-1', '--pretty=%B'])).toMatch('test') | ||
expect(await readFile('test.js')).toEqual(fileFixtures.prettyJSWithChanges) | ||
}) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters