Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

fix: get all commits from pr #723

Open
wants to merge 16 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/helpers/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,25 @@ export const getCommitsOnPullRequest = async (pullNumber: number) => {
const context = getBotContext();
const payload = getBotContext().payload as Payload;
try {
const { data: commits } = await context.octokit.rest.pulls.listCommits({
owner: payload.repository.owner.login,
repo: payload.repository.name,
pull_number: pullNumber,
});
return commits;
const perPage = 100;
let curPage = 1;
const allCommits = [];
let fetchDone = false;
while (!fetchDone) {
const { data: commits } = await context.octokit.rest.pulls.listCommits({
owner: payload.repository.owner.login,
repo: payload.repository.name,
pull_number: pullNumber,
per_page: 100,
0xcodercrane marked this conversation as resolved.
Show resolved Hide resolved
page: curPage,
});
allCommits.push(...commits);
if (commits.length < perPage) {
fetchDone = true;
return allCommits;
0xcodercrane marked this conversation as resolved.
Show resolved Hide resolved
} else curPage++;
}
return allCommits;
} catch (e: unknown) {
logger.debug(`Fetching pull request commits failed!, reason: ${e}`);
return [];
Expand Down
Loading