@@ -80,21 +80,22 @@ async function checkCommitMessages(args) {
80
80
// Check messages
81
81
let result = true;
82
82
core.info(`Checking commit messages against "${args.pattern}"...`);
83
+ let debugRegexMsg = '';
83
84
for (const message of args.messages) {
84
85
if (checkMessage(message, args.pattern, args.flags)) {
85
86
core.info(`- OK: "${message}"`);
86
87
}
87
88
else {
88
89
core.info(`- failed: "${message}"`);
89
90
if (args.debugRegex !== null) {
90
- core.info( debugRegexMatching(args.debugRegex, message) );
91
+ debugRegexMsg = '\n' + debugRegexMatching(args.debugRegex, message);
91
92
}
92
93
result = false;
93
94
}
94
95
}
95
96
// Throw error in case of failed test
96
97
if (!result) {
97
- throw new Error(args.error);
98
+ throw new Error(args.error + debugRegexMsg );
98
99
}
99
100
}
100
101
exports.checkCommitMessages = checkCommitMessages;
@@ -152,13 +153,13 @@ const debugRegexMatching = (regexes, str) => {
152
153
return `Trailing characters: "${str}"
153
154
--------------------------------
154
155
Context: "${leftDots}${copyStr.slice(paddingLeft, Math.min(copyStr.length, matchesUntil + 10)).replaceAll('\n', '')}${rightDots}"
155
- ${" ".repeat(matchesUntil - paddingLeft)}^`;
156
+ ${' '.repeat(leftDots.length)} ${" ".repeat(matchesUntil - paddingLeft)}^`;
156
157
}
157
158
else {
158
159
return `The regex stopped matching at index: ${matchesUntil}.
159
- Expected: " ${rgx}"
160
+ Expected: ${rgx}
160
161
Context: "${leftDots}${copyStr.slice(paddingLeft, paddingRight).replaceAll('\n', '')}${rightDots}"
161
- ${" ".repeat(matchesUntil - paddingLeft)}^${"~".repeat(paddingRight - matchesUntil)}`;
162
+ ${' '.repeat(leftDots.length)} ${" ".repeat(matchesUntil - paddingLeft)}^${"~".repeat(paddingRight - matchesUntil)}`;
162
163
}
163
164
}
164
165
};
0 commit comments