Skip to content

Commit

Permalink
feat: match more Resolves patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
zugdev committed Dec 9, 2024
1 parent a33a8d4 commit e6d2b36
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/home/fetch-github/fetch-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,17 @@ 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;

if (issueUrlMatch) {
// 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;

Expand Down

0 comments on commit e6d2b36

Please sign in to comment.