Skip to content

Conversation

@TonyWhiteSMS
Copy link

@TonyWhiteSMS TonyWhiteSMS commented Jul 27, 2025

When searching the branch for the commitId, use pagination to search more commits

Fixes #144

When searching the branch for the commitId, use pagination to search more commits
Copy link
Collaborator

@meeroslav meeroslav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current solution doesn't work.

Can you replace it with a suggested async iterator and build the code so that the PR contains both source and the dist files?

Thanks!

Comment on lines +260 to +281
let commitFound = false;
yield octokit.paginate("GET /repos/{owner}/{repo}/commits", {
owner,
repo,
sha: branchName,
per_page: 100,
}, (response, done) => {
if (response.data.some((commit: { sha: string }) => commit.sha === commitSha)) {
commitFound = true;
done(); // Stop pagination if commit is found
}

return commits.data.some(
(commit: { sha: string }) => commit.sha === commitSha,
// Decrement maxPages and stop if limit reached
if (maxPages <= 1) { // Use <= 1 because it's decremented after checking
done();
}
maxPages--;
return response;
}
);

return commitFound;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work outside of a generator. Can you modify it to use async iterrator instead?

    let maxPages = 20; // TODO: This could be made an input param to allow larger/longer searches
    for await (const response of octokit.paginate.iterator(
      'GET /repos/{owner}/{repo}/commits',
      {
        owner,
        repo,
        sha: branchName,
        per_page: 100,
      },
    )) {
      if (
        response.data.some(
          (commit: { sha: string }) => commit.sha === commitSha,
        )
      ) {
        return true;
      }
      maxPages--;
      if (maxPages <= 1) {
        break;
      }
    }

    return false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Commit not found if more than 100 commits on a branch

2 participants