diff --git a/src/handlers/assign/auto.ts b/src/handlers/assign/auto.ts index c4716ac99..be9516e4d 100644 --- a/src/handlers/assign/auto.ts +++ b/src/handlers/assign/auto.ts @@ -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) { @@ -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; } diff --git a/src/helpers/parser.ts b/src/helpers/parser.ts index 71993d7aa..e49eae9d7 100644 --- a/src/helpers/parser.ts +++ b/src/helpers/parser.ts @@ -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; @@ -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 => {