From e6d2b36a7184237d29976ffbedc8c35baf058c8a Mon Sep 17 00:00:00 2001 From: zugdev Date: Mon, 9 Dec 2024 11:47:36 -0300 Subject: [PATCH] feat: match more Resolves patterns --- src/home/fetch-github/fetch-data.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/home/fetch-github/fetch-data.ts b/src/home/fetch-github/fetch-data.ts index 43ce8e1..71e9ab4 100644 --- a/src/home/fetch-github/fetch-data.ts +++ b/src/home/fetch-github/fetch-data.ts @@ -89,6 +89,7 @@ async function fetchIssueFromPullRequest(pullRequest: GitHubPullRequest): Promis // Match the issue reference in the PR body const issueUrlMatch = pullRequest.body.match(/Resolves (https:\/\/github\.com\/(.+?)\/(.+?)\/issues\/(\d+))/); const issueNumberMatch = pullRequest.body.match(/Resolves #(\d+)/); + const issueMarkdownLinkMatch = pullRequest.body.match(/Resolves \[\s*#(\d+)\s*\]/); let apiUrl: string; @@ -96,9 +97,9 @@ async function fetchIssueFromPullRequest(pullRequest: GitHubPullRequest): Promis // Full URL to the issue is provided const [, , owner, repo, issueNumber] = issueUrlMatch; apiUrl = `https://api.github.com/repos/${owner}/${repo}/issues/${issueNumber}`; - } else if (issueNumberMatch) { + } else if (issueNumberMatch || issueMarkdownLinkMatch) { // Only issue number is provided, construct API URL using current repo info - const issueNumber = issueNumberMatch[1]; + const issueNumber = issueNumberMatch ? issueNumberMatch[1] : issueMarkdownLinkMatch![1]; const pullRequestUrlMatch = pullRequest.url.match(/repos\/(.+?)\/(.+?)\/pulls\/\d+/); if (!pullRequestUrlMatch) return null;