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

Commit

Permalink
chore: return string array
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcodercrane committed Oct 16, 2023
1 parent 9168f4d commit 3a31f58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/handlers/assign/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const checkPullRequests = async () => {
pull_number: pull.number,
});

if (!linkedIssues) continue;

for (const linkedIssue of linkedIssues) {
// if pullRequestLinked is empty, continue
if (linkedIssue == "" || !pull.user || !linkedIssue) {
Expand All @@ -34,9 +32,9 @@ export const checkPullRequests = async () => {

const connectedPull = await getPullByNumber(context, pull.number);

// Newly created PULL (draft or direct) pull does have same `created_at` and `updated_at`.
// The new PR, whether it's in draft or in direct form, it has identical `created_at` and `updated_at` timestamps.
if (connectedPull?.created_at !== connectedPull?.updated_at) {
logger.debug("It's an updated Pull Request, reverting");
logger.debug("Skipping because it's not a new PR");
continue;
}

Expand Down
11 changes: 4 additions & 7 deletions src/helpers/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ export interface LinkedPR {

export const gitLinkedIssueParser = async ({ owner, repo, pull_number }: GitParser) => {
const logger = getLogger();
const linkedIssueUrls = [];
try {
const { data } = await axios.get(`https://github.com/${owner}/${repo}/pull/${pull_number}`);
const dom = parse(data);
const devForm = dom.querySelector("[data-target='create-branch.developmentForm']") as HTMLElement;
const linkedIssues = devForm.querySelectorAll(".my-1");

if (linkedIssues.length === 0) {
return null;
}

const linkedIssueUrls = [];
if (linkedIssues.length === 0) return [];

for (const linkedIssue of linkedIssues) {
const issueUrl = linkedIssue.querySelector("a")?.attrs?.href;
Expand All @@ -49,11 +46,11 @@ export const gitLinkedIssueParser = async ({ owner, repo, pull_number }: GitPars

linkedIssueUrls.push(issueUrl);
}
return linkedIssueUrls;
} catch (error) {
logger.error(`${JSON.stringify(error)}`);
return null;
}

return linkedIssueUrls;
};

export const gitLinkedPrParser = async ({ owner, repo, issue_number }: GitParser): Promise<LinkedPR[]> => {
Expand Down

0 comments on commit 3a31f58

Please sign in to comment.