Skip to content

Commit d9d62d8

Browse files
committed
chore few things
1 parent c68a7bf commit d9d62d8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/commit-message-checker.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,23 @@ export async function checkCommitMessages(
6969

7070
core.info(`Checking commit messages against "${args.pattern}"...`)
7171

72+
let debugRegexMsg = '';
73+
7274
for (const message of args.messages) {
7375
if (checkMessage(message, args.pattern, args.flags)) {
7476
core.info(`- OK: "${message}"`)
7577
} else {
7678
core.info(`- failed: "${message}"`)
7779
if (args.debugRegex !== null) {
78-
args.error += '\n' + debugRegexMatching(args.debugRegex, message);
80+
debugRegexMsg = '\n' + debugRegexMatching(args.debugRegex, message);
7981
}
8082
result = false;
8183
}
8284
}
8385

8486
// Throw error in case of failed test
8587
if (!result) {
86-
throw new Error(args.error)
88+
throw new Error(args.error + debugRegexMsg)
8789
}
8890
}
8991

@@ -149,12 +151,12 @@ const debugRegexMatching = (regexes: (string | string[])[], str: string): string
149151
return `Trailing characters: "${str}"
150152
--------------------------------
151153
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)}^`;
153155
} else {
154156
return `The regex stopped matching at index: ${matchesUntil}.
155-
Expected: "${rgx}"
157+
Expected: ${rgx}
156158
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)}`;
158160
}
159161
}
160162
}

0 commit comments

Comments
 (0)