@@ -69,21 +69,23 @@ export async function checkCommitMessages(
69
69
70
70
core . info ( `Checking commit messages against "${ args . pattern } "...` )
71
71
72
+ let debugRegexMsg = '' ;
73
+
72
74
for ( const message of args . messages ) {
73
75
if ( checkMessage ( message , args . pattern , args . flags ) ) {
74
76
core . info ( `- OK: "${ message } "` )
75
77
} else {
76
78
core . info ( `- failed: "${ message } "` )
77
79
if ( args . debugRegex !== null ) {
78
- args . error + = '\n' + debugRegexMatching ( args . debugRegex , message ) ;
80
+ debugRegexMsg = '\n' + debugRegexMatching ( args . debugRegex , message ) ;
79
81
}
80
82
result = false ;
81
83
}
82
84
}
83
85
84
86
// Throw error in case of failed test
85
87
if ( ! result ) {
86
- throw new Error ( args . error )
88
+ throw new Error ( args . error + debugRegexMsg )
87
89
}
88
90
}
89
91
@@ -149,12 +151,12 @@ const debugRegexMatching = (regexes: (string | string[])[], str: string): string
149
151
return `Trailing characters: "${ str } "
150
152
--------------------------------
151
153
Context: "${ leftDots } ${ copyStr . slice ( paddingLeft , Math . min ( copyStr . length , matchesUntil + 10 ) ) . replaceAll ( '\n' , '' ) } ${ rightDots } "
152
- ${ leftDots . replace ( '…' , ' ' ) } ${ " " . repeat ( matchesUntil - paddingLeft ) } ^` ;
154
+ ${ ' ' . repeat ( leftDots . length ) } ${ " " . repeat ( matchesUntil - paddingLeft ) } ^` ;
153
155
} else {
154
156
return `The regex stopped matching at index: ${ matchesUntil } .
155
- Expected: " ${ rgx } "
157
+ Expected: ${ rgx }
156
158
Context: "${ leftDots } ${ copyStr . slice ( paddingLeft , paddingRight ) . replaceAll ( '\n' , '' ) } ${ rightDots } "
157
- ${ leftDots . replace ( '…' , ' ' ) } ${ " " . repeat ( matchesUntil - paddingLeft ) } ^${ "~" . repeat ( paddingRight - matchesUntil ) } ` ;
159
+ ${ ' ' . repeat ( leftDots . length ) } ${ " " . repeat ( matchesUntil - paddingLeft ) } ^${ "~" . repeat ( paddingRight - matchesUntil ) } ` ;
158
160
}
159
161
}
160
162
}
0 commit comments