From 4c6792702de5ee3ca9947f603245e2125a082cbe Mon Sep 17 00:00:00 2001 From: Romeo Date: Fri, 6 Mar 2020 11:22:33 +0000 Subject: [PATCH] Simplify file fetching loop --- dist/main.js | 36 ++++++++++++++---------------------- src/files.js | 36 ++++++++++++++---------------------- 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/dist/main.js b/dist/main.js index d93fefa7..3962af32 100644 --- a/dist/main.js +++ b/dist/main.js @@ -22922,30 +22922,22 @@ async function changedFiles(github, repo, pr, count) { const files = []; for (const page = 0; page * perPage < count; page++) { - await Promise.all( - commits.map(async function(commit) { - if (!commit.distinct) { - return - } - - const response = await github.pulls.listFiles({ - ...repo, - pull_number: pr, - page, - per_page: perPage, - }); + const response = await github.pulls.listFiles({ + ...repo, + pull_number: pr, + page, + per_page: perPage, + }); - if (!response || !response.data) { - return - } + if (!response || !response.data) { + return + } - for (const file of result.data) { - if (file.status === "added" || file.status === "modified") { - files.push(file.filename); - } - } - }), - ); + for (const file of result.data) { + if (file.status === "added" || file.status === "modified" || file.status === "renamed") { + files.push(file.filename); + } + } } return files diff --git a/src/files.js b/src/files.js index 82d16da3..f27d3613 100644 --- a/src/files.js +++ b/src/files.js @@ -4,30 +4,22 @@ export async function changedFiles(github, repo, pr, count) { const files = [] for (const page = 0; page * perPage < count; page++) { - await Promise.all( - commits.map(async function(commit) { - if (!commit.distinct) { - return - } + const response = await github.pulls.listFiles({ + ...repo, + pull_number: pr, + page, + per_page: perPage, + }) - const response = await github.pulls.listFiles({ - ...repo, - pull_number: pr, - page, - per_page: perPage, - }) + if (!response || !response.data) { + return + } - if (!response || !response.data) { - return - } - - for (const file of result.data) { - if (file.status === "added" || file.status === "modified") { - files.push(file.filename) - } - } - }), - ) + for (const file of result.data) { + if (file.status === "added" || file.status === "modified" || file.status === "renamed") { + files.push(file.filename) + } + } } return files