getCommitInfoForFiles = async prNumber => {
const files = await fetchGithub(`/repos/${repo}/pulls/${prNumber}/files`);
const fileNames = files.map((f) => f.filename);
const commits = new Set();
for await (const fileCommits of files.map((f) =>
fetchGithub(`/repos/${repo}/commits`, {
path: f.filename,
per_page: limit
})
)) {
for (let { sha } of fileCommits) {
commits.add(sha);
}
}
const commitInfo = await Promise.all(
[...commits].map((c) => fetchGithub(`/repos/${repo}/commits/${c}`))
);
return parseCommitInfo(fileNames, commitInfo);
}