@@ -435,6 +435,38 @@ describe('exec command utilities', () => {
435435 expect ( lines [ lines . length - 1 ] ) . toBe ( `Change-Id: ${ changeId } ` ) ;
436436 } ) ;
437437
438+ it ( 'should not treat Solution: lines as trailers' , ( ) => {
439+ const message = 'feat: add new feature\n\nSolution: blah blah blah' ;
440+ const changeId = 'I123456789abcdef0123456789abcdef01234567' ;
441+ const result = insertTrailers ( message , { ChangeId : changeId } ) ;
442+ const lines = result . split ( '\n' ) ;
443+ const solutionIndex = lines . findIndex (
444+ ( line ) => line === 'Solution: blah blah blah'
445+ ) ;
446+ const changeIdIndex = lines . findIndex ( ( line ) =>
447+ line . startsWith ( 'Change-Id:' )
448+ ) ;
449+ expect ( solutionIndex ) . toBeGreaterThan ( - 1 ) ;
450+ expect ( changeIdIndex ) . toBeGreaterThan ( - 1 ) ;
451+ expect ( solutionIndex ) . toBeLessThan ( changeIdIndex ) ;
452+ expect ( lines [ changeIdIndex - 1 ] ) . toBe ( '' ) ;
453+ } ) ;
454+
455+ it ( 'should not treat dash-leading tokens as trailers' , ( ) => {
456+ const message = 'feat: add new feature\n\n-Foo: bar' ;
457+ const changeId = 'I123456789abcdef0123456789abcdef01234567' ;
458+ const result = insertTrailers ( message , { ChangeId : changeId } ) ;
459+ const lines = result . split ( '\n' ) ;
460+ const dashTokenIndex = lines . findIndex ( ( line ) => line === '-Foo: bar' ) ;
461+ const changeIdIndex = lines . findIndex ( ( line ) =>
462+ line . startsWith ( 'Change-Id:' )
463+ ) ;
464+ expect ( dashTokenIndex ) . toBeGreaterThan ( - 1 ) ;
465+ expect ( changeIdIndex ) . toBeGreaterThan ( - 1 ) ;
466+ expect ( dashTokenIndex ) . toBeLessThan ( changeIdIndex ) ;
467+ expect ( lines [ changeIdIndex - 1 ] ) . toBe ( '' ) ;
468+ } ) ;
469+
438470 it ( 'should insert Change-Id before non-comment trailers' , ( ) => {
439471 const message =
440472 'feat: add new feature\n\nThis is a new feature\n\nSigned-off-by: user@example.com' ;
0 commit comments