@@ -329,13 +329,50 @@ test('should handle --amend with signoff', async () => {
329
329
expect ( commit ) . toBeTruthy ( ) ;
330
330
} , 10000 ) ;
331
331
332
- test ( 'should fail with an empty message and a commentChar is set ' , async ( ) => {
332
+ test ( 'it uses parserOpts.commentChar when not using edit mode ' , async ( ) => {
333
333
const cwd = await gitBootstrap ( 'fixtures/comment-char' ) ;
334
- await execa ( 'git' , [ 'config' , '--local' , 'core.commentChar' , '$' ] , { cwd} ) ;
335
- await fs . writeFile ( path . join ( cwd , '.git' , 'COMMIT_EDITMSG' ) , '#1234' ) ;
334
+ const input = 'header: foo\n$body\n' ;
335
+
336
+ const actual = await cli ( [ ] , { cwd} ) ( input ) ;
337
+ expect ( actual . stdout ) . toContain ( '[body-empty]' ) ;
338
+ expect ( actual . exitCode ) . toBe ( 1 ) ;
339
+ } ) ;
340
+
341
+ test ( "it doesn't use parserOpts.commentChar when using edit mode" , async ( ) => {
342
+ const cwd = await gitBootstrap ( 'fixtures/comment-char' ) ;
343
+ await fs . writeFile (
344
+ path . join ( cwd , '.git' , 'COMMIT_EDITMSG' ) ,
345
+ 'header: foo\n\n$body\n'
346
+ ) ;
347
+
348
+ const actual = await cli ( [ '--edit' , '.git/COMMIT_EDITMSG' ] , { cwd} ) ( ) ;
349
+ expect ( actual . stdout ) . not . toContain ( '[body-empty]' ) ;
350
+ expect ( actual . exitCode ) . toBe ( 0 ) ;
351
+ } ) ;
352
+
353
+ test ( 'it uses core.commentChar git config when using edit mode' , async ( ) => {
354
+ const cwd = await gitBootstrap ( 'fixtures/comment-char' ) ;
355
+ await execa ( 'git' , [ 'config' , 'core.commentChar' , '$' ] , { cwd} ) ;
356
+ await fs . writeFile (
357
+ path . join ( cwd , '.git' , 'COMMIT_EDITMSG' ) ,
358
+ 'header: foo\n\n$body\n'
359
+ ) ;
360
+
361
+ const actual = await cli ( [ '--edit' , '.git/COMMIT_EDITMSG' ] , { cwd} ) ( ) ;
362
+ expect ( actual . stdout ) . toContain ( '[body-empty]' ) ;
363
+ expect ( actual . exitCode ) . toBe ( 1 ) ;
364
+ } ) ;
365
+
366
+ test ( 'it falls back to # for core.commentChar when using edit mode' , async ( ) => {
367
+ const cwd = await gitBootstrap ( 'fixtures/comment-char' ) ;
368
+ await execa ( 'git' , [ 'config' , 'core.commentChar' , '' ] , { cwd} ) ;
369
+ await fs . writeFile (
370
+ path . join ( cwd , '.git' , 'COMMIT_EDITMSG' ) ,
371
+ 'header: foo\n\n#body\n'
372
+ ) ;
336
373
337
374
const actual = await cli ( [ '--edit' , '.git/COMMIT_EDITMSG' ] , { cwd} ) ( ) ;
338
- expect ( actual . stdout ) . toContain ( '[subject -empty]' ) ;
375
+ expect ( actual . stdout ) . toContain ( '[body -empty]' ) ;
339
376
expect ( actual . exitCode ) . toBe ( 1 ) ;
340
377
} ) ;
341
378
0 commit comments