@@ -80,21 +80,22 @@ async function checkCommitMessages(args) {
8080 // Check messages
8181 let result = true;
8282 core.info(`Checking commit messages against "${args.pattern}"...`);
83+ let debugRegexMsg = '';
8384 for (const message of args.messages) {
8485 if (checkMessage(message, args.pattern, args.flags)) {
8586 core.info(`- OK: "${message}"`);
8687 }
8788 else {
8889 core.info(`- failed: "${message}"`);
8990 if (args.debugRegex !== null) {
90- core.info( debugRegexMatching(args.debugRegex, message) );
91+ debugRegexMsg = '\n' + debugRegexMatching(args.debugRegex, message);
9192 }
9293 result = false;
9394 }
9495 }
9596 // Throw error in case of failed test
9697 if (!result) {
97- throw new Error(args.error);
98+ throw new Error(args.error + debugRegexMsg );
9899 }
99100}
100101exports.checkCommitMessages = checkCommitMessages;
@@ -152,13 +153,13 @@ const debugRegexMatching = (regexes, str) => {
152153 return `Trailing characters: "${str}"
153154--------------------------------
154155Context: "${leftDots}${copyStr.slice(paddingLeft, Math.min(copyStr.length, matchesUntil + 10)).replaceAll('\n', '')}${rightDots}"
155- ${" ".repeat(matchesUntil - paddingLeft)}^`;
156+ ${' '.repeat(leftDots.length)} ${" ".repeat(matchesUntil - paddingLeft)}^`;
156157 }
157158 else {
158159 return `The regex stopped matching at index: ${matchesUntil}.
159- Expected: " ${rgx}"
160+ Expected: ${rgx}
160161Context: "${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)}`;
162163 }
163164 }
164165};
0 commit comments