Skip to content

Commit 093c7ea

Browse files
committed
fix(cli): make tests independent of global git config (conventional-changelog#3190)
- Don't apply global changes - Set $HOME to ensure default global settings aren't picked up
1 parent 33be5ab commit 093c7ea

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

@commitlint/cli/src/cli.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ test("it doesn't use parserOpts.commentChar when using edit mode", async () => {
352352

353353
test('it uses core.commentChar git config when using edit mode', async () => {
354354
const cwd = await gitBootstrap('fixtures/comment-char');
355-
await execa('git', ['config', 'core.commentChar', '$'], {cwd});
355+
await execa('git', ['config', '--local', 'core.commentChar', '$'], {cwd});
356356
await fs.writeFile(
357357
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
358358
'header: foo\n\n$body\n'
@@ -365,7 +365,6 @@ test('it uses core.commentChar git config when using edit mode', async () => {
365365

366366
test('it falls back to # for core.commentChar when using edit mode', async () => {
367367
const cwd = await gitBootstrap('fixtures/comment-char');
368-
await execa('git', ['config', '--unset', 'core.commentChar'], {cwd});
369368
await fs.writeFile(
370369
path.join(cwd, '.git', 'COMMIT_EDITMSG'),
371370
'header: foo\n\n#body\n'

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"publish": "lerna publish --conventional-commits",
2020
"reinstall": "yarn clean && yarn install",
2121
"start": "yarn watch",
22-
"test": "jest",
23-
"test-ci": "jest --runInBand",
22+
"test": "HOME=$PWD jest",
23+
"test-ci": "HOME=$PWD jest --runInBand",
2424
"postinstall": "yarn husky install"
2525
},
2626
"commitlint": {
@@ -106,4 +106,4 @@
106106
"resolutions": {
107107
"**/lodash": "^4.17.19"
108108
}
109-
}
109+
}

0 commit comments

Comments
 (0)