feat: fetch data for prs that need retest
This commit is contained in:
23
src/lib/get_commits.mjs
Normal file
23
src/lib/get_commits.mjs
Normal file
@@ -0,0 +1,23 @@
|
||||
function formatCommit(commit) {
|
||||
return {
|
||||
sha: commit.sha,
|
||||
owner: commit.committer.login,
|
||||
message: commit.commit.message,
|
||||
};
|
||||
}
|
||||
|
||||
function formatCommits(commits, lastOnly) {
|
||||
if (lastOnly) return formatCommit(commits.pop());
|
||||
return commits.map(c => formatCommit(c));
|
||||
}
|
||||
|
||||
export default async function getCommits(repo, id, lastOnly = true) {
|
||||
const commits = await repo.pulls(id).commits.fetch();
|
||||
|
||||
if (commits.lastPage) {
|
||||
const { items } = await commits.lastPage.fetch();
|
||||
return formatCommits(items, lastOnly);
|
||||
}
|
||||
|
||||
return formatCommits(commits.items, lastOnly);
|
||||
}
|
||||
Reference in New Issue
Block a user