Skip to content

Commit

Permalink
fix: a #123 style has that wasn't a valid PR was causing a fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrenskers committed Aug 17, 2021
1 parent b31b782 commit 6730d9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7166,8 +7166,13 @@ async function parseCommitMessage(message, repoUrl, fetchUserFunc) {
const found = cAst.subject.match(PR_REGEX);
if (found) {
const pullNumber = found[1];
const { username, userUrl } = await fetchUserFunc(pullNumber);
cAst.subject = cAst.subject.replace(PR_REGEX, () => `[#${pullNumber}](${repoUrl}/pull/${pullNumber}) by [${username}](${userUrl})`);

try {
const { username, userUrl } = await fetchUserFunc(pullNumber);
cAst.subject = cAst.subject.replace(PR_REGEX, () => `[#${pullNumber}](${repoUrl}/pull/${pullNumber}) by [${username}](${userUrl})`);
} catch (error) {
// We found a #123 style hash, but it wasn't a valid PR. Ignore.
}
}

return cAst;
Expand Down
9 changes: 7 additions & 2 deletions src/parseCommitMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ async function parseCommitMessage(message, repoUrl, fetchUserFunc) {
const found = cAst.subject.match(PR_REGEX);
if (found) {
const pullNumber = found[1];
const { username, userUrl } = await fetchUserFunc(pullNumber);
cAst.subject = cAst.subject.replace(PR_REGEX, () => `[#${pullNumber}](${repoUrl}/pull/${pullNumber}) by [${username}](${userUrl})`);

try {
const { username, userUrl } = await fetchUserFunc(pullNumber);
cAst.subject = cAst.subject.replace(PR_REGEX, () => `[#${pullNumber}](${repoUrl}/pull/${pullNumber}) by [${username}](${userUrl})`);
} catch (error) {
// We found a #123 style hash, but it wasn't a valid PR. Ignore.
}
}

return cAst;
Expand Down

0 comments on commit 6730d9b

Please sign in to comment.