Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Hotfix: check org and repo for linked issue #789

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/helpers/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,26 @@ export const gitLinkedIssueParser = async ({ owner, repo, pull_number }: GitPars
return null;
}

const issueUrl = linkedIssues[0].querySelector("a")?.attrs?.href || "";
return issueUrl;
for (const linkedIssue of linkedIssues) {
const issueUrl = linkedIssue.querySelector("a")?.attrs?.href;

if (!issueUrl) continue;

const parts = issueUrl.split("/");

// check if array size is at least 4
if (parts.length < 4) continue;

// extract the organization name and repo name from the link:(e.g. "
const issueOrganization = parts[parts.length - 4];
const issueRepository = parts[parts.length - 3];

if (`${issueOrganization}/${issueRepository}` !== `${owner}/${repo}`) continue;

return issueUrl;
wannacfuture marked this conversation as resolved.
Show resolved Hide resolved
}

return null;
} catch (error) {
logger.error(`${JSON.stringify(error)}`);
return null;
Expand Down
Loading