-
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: print a better warning when the initial commit is missing
lint-staged uses git stashes internally, and git stashes require the initial commit to work
- Loading branch information
Showing
4 changed files
with
44 additions
and
13 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
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 |
---|---|---|
|
@@ -383,7 +383,7 @@ describe('runAll', () => { | |
" | ||
ERROR | ||
× lint-staged failed due to a git error. | ||
Any lost modifications can be restored from a git stash: | ||
ERROR Any lost modifications can be restored from a git stash: | ||
> git stash list | ||
stash@{0}: On master: automatic lint-staged backup | ||
|
@@ -774,3 +774,28 @@ describe('runAll', () => { | |
expect(await readFile('test.js', submoduleDir)).toEqual(testJsFilePretty) | ||
}) | ||
}) | ||
|
||
describe('runAll', () => { | ||
it('Should throw when run on an empty git repo without an initial commit', async () => { | ||
const tmpDir = await createTempDir() | ||
const cwd = normalize(tmpDir) | ||
const logger = makeConsoleMock() | ||
|
||
await execGit('init', { cwd }) | ||
await execGit(['config', 'user.name', '"test"'], { cwd }) | ||
await execGit(['config', 'user.email', '"[email protected]"'], { cwd }) | ||
await appendFile('test.js', testJsFilePretty, cwd) | ||
await execGit(['add', 'test.js'], { cwd }) | ||
await expect( | ||
runAll({ config: { '*.js': 'prettier --list-different' }, cwd, quiet: true }, logger) | ||
).rejects.toThrowErrorMatchingInlineSnapshot(`"Something went wrong"`) | ||
expect(logger.printHistory()).toMatchInlineSnapshot(` | ||
" | ||
ERROR | ||
× lint-staged failed due to a git error. | ||
ERROR | ||
The initial commit is needed for lint-staged to work. | ||
Please use the --no-verify flag to skip running lint-staged." | ||
`) | ||
}) | ||
}) |