@@ -429,6 +429,11 @@ function normalizeType(s) {
429429
430430async function populateConventional ( commit , repoUrl , versionPattern , tags ) {
431431 for ( const line of commit . message . split ( '\n' ) ) {
432+ if ( ! line )
433+ {
434+ continue
435+ }
436+
432437 if ( ! commit . subject ) {
433438 // Is subject
434439 commit . subject = line
@@ -452,10 +457,14 @@ async function populateConventional(commit, repoUrl, versionPattern, tags) {
452457 }
453458
454459 // Subject populated: parse as body, footer, or tag
455- const footerRegex = / ( ( [ ^ ] + ) : ) | ( ( [ ^ ] + ) # ) | ( ( B R E A K I N G C H A N G E ) : ) /
456- const m = line . match ( footerRegex )
460+ // This regular expression matches lines that represent footers in a commit message.
461+ // It matches the following patterns:
462+ // 1. `([^ ]+): ` - A key followed by a colon and a space (e.g., "Fixes: ")
463+ // 2. `([^ ]+) #` - A key followed by a space and a hash symbol (e.g., "Issue #")
464+ // 3. `(BREAKING CHANGE): ` - The literal string "BREAKING CHANGE" followed by a colon and a space
465+ const footerKeyRegex = / ^ ( ( [ ^ ] + ) : ) | ( ( [ ^ ] + ) # ) | ( ( B R E A K I N G C H A N G E ) : ) /
466+ const m = line . match ( footerKeyRegex )
457467 if ( m ) {
458- // is a footer
459468 const footerKey = m [ 1 ] ? m [ 2 ] : m [ 3 ] ? m [ 4 ] : m [ 5 ] ? m [ 6 ] : null
460469 if ( footerKey ) {
461470 const offset = m [ 1 ] || m [ 5 ] ? 2 : 1
@@ -467,6 +476,7 @@ async function populateConventional(commit, repoUrl, versionPattern, tags) {
467476 continue
468477 }
469478
479+ // Check for a footer with no key and value
470480 if ( [ 'breaking' , 'breaking-change' , 'breaking change' ] . includes ( line . toLowerCase ( ) ) ) {
471481 // footer with no key and value
472482 // -> the whole message is breaking change footer
@@ -477,7 +487,7 @@ async function populateConventional(commit, repoUrl, versionPattern, tags) {
477487 // #<tag-expr>
478488 // The commit can contain a tag, which is just a string identifier
479489 // for whatever purpose the user wants to use it for.
480- const tagRegex = / # ( \S + ) /
490+ const tagRegex = / ^ \s * # ( \S + ) \s * $ /
481491 const tagMatch = line . match ( tagRegex )
482492 if ( tagMatch ) {
483493 commit . tags . push ( tagMatch [ 1 ] )
0 commit comments