Skip to content

Commit

Permalink
Simplify file fetching loop
Browse files Browse the repository at this point in the history
  • Loading branch information
romeovs committed Mar 6, 2020
1 parent 6668b90 commit 4c67927
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 44 deletions.
36 changes: 14 additions & 22 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 14 additions & 22 deletions src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c67927

Please sign in to comment.