Skip to content

Commit 80a2c81

Browse files
committed
Fixed gettign nested PR issues
1 parent f1ce410 commit 80a2c81

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

dist/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -8378,7 +8378,7 @@ const {
83788378
} = __nccwpck_require__(6480)
83798379

83808380
exports.prWorkflow = async function (owner, repo, columnId, projectName) {
8381-
const destBranch = core.getInput('branch');
8381+
const destBranch = core.getInput('branch');
83828382

83838383
if (destBranch !== github.context.payload.pull_request.base.ref || github.context.payload.pull_request.base.merged === false) {
83848384
return;
@@ -8394,8 +8394,7 @@ exports.prWorkflow = async function (owner, repo, columnId, projectName) {
83948394
return;
83958395
}
83968396
const cursor = lastPRs.length === 1 ? false : lastPRs[0].cursor;
8397-
8398-
let issues = (await findAllNestedPullRequestsIssues(owner, repo, destBranch, cursor));
8397+
let issues = (await findAllNestedPullRequestsIssues(owner, repo, destBranch, cursor)).filter((v, i, a) => a.findIndex(v2 => (v2.id === v.id)) === i);
83998398

84008399
if (issues.length === 0) {
84018400
console.log(`Not found any issues related to current PR and all children PRs`);
@@ -8468,6 +8467,7 @@ async function lastPullRequests(owner, repo, destinationBranch) {
84688467
const findAllNestedPullRequestsIssues = async (owner, repo, destinationBranch, endCursor) => {
84698468
let issues = [];
84708469
let pullRequests = await findAllNestedPullRequests(owner, repo, destinationBranch, endCursor);
8470+
84718471
if (pullRequests.length) {
84728472
for (let i = 0; i < pullRequests.length; i++) {
84738473
let {closingIssuesReferences: {edges: refIssues}} = pullRequests[i].node;
@@ -8477,7 +8477,7 @@ const findAllNestedPullRequestsIssues = async (owner, repo, destinationBranch, e
84778477
}
84788478
}
84798479
let results = await findAllNestedPullRequestsIssues(owner, repo, pullRequests[i].node.headRefName, endCursor);
8480-
return [...issues, ...results];
8480+
issues = [...issues, ...results];
84818481
}
84828482
}
84838483

src/pr-workflow.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
} = require('./queries')
1010

1111
exports.prWorkflow = async function (owner, repo, columnId, projectName) {
12-
const destBranch = core.getInput('branch');
12+
const destBranch = core.getInput('branch');
1313

1414
if (destBranch !== github.context.payload.pull_request.base.ref || github.context.payload.pull_request.base.merged === false) {
1515
return;
@@ -25,8 +25,7 @@ exports.prWorkflow = async function (owner, repo, columnId, projectName) {
2525
return;
2626
}
2727
const cursor = lastPRs.length === 1 ? false : lastPRs[0].cursor;
28-
29-
let issues = (await findAllNestedPullRequestsIssues(owner, repo, destBranch, cursor));
28+
let issues = (await findAllNestedPullRequestsIssues(owner, repo, destBranch, cursor)).filter((v, i, a) => a.findIndex(v2 => (v2.id === v.id)) === i);
3029

3130
if (issues.length === 0) {
3231
console.log(`Not found any issues related to current PR and all children PRs`);

src/queries.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async function lastPullRequests(owner, repo, destinationBranch) {
4242
const findAllNestedPullRequestsIssues = async (owner, repo, destinationBranch, endCursor) => {
4343
let issues = [];
4444
let pullRequests = await findAllNestedPullRequests(owner, repo, destinationBranch, endCursor);
45+
4546
if (pullRequests.length) {
4647
for (let i = 0; i < pullRequests.length; i++) {
4748
let {closingIssuesReferences: {edges: refIssues}} = pullRequests[i].node;
@@ -51,7 +52,7 @@ const findAllNestedPullRequestsIssues = async (owner, repo, destinationBranch, e
5152
}
5253
}
5354
let results = await findAllNestedPullRequestsIssues(owner, repo, pullRequests[i].node.headRefName, endCursor);
54-
return [...issues, ...results];
55+
issues = [...issues, ...results];
5556
}
5657
}
5758

0 commit comments

Comments
 (0)