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

Commit

Permalink
Merge pull request #231 from githubnext/aw/handle-long-branches-list
Browse files Browse the repository at this point in the history
fix: fetch full list of paginated branches
  • Loading branch information
Wattenberger authored Dec 6, 2022
2 parents 17056cc + 0f23474 commit d1ad528
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions components/repo-detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ export function RepoDetail() {
branchName = branch.name;
path = branchPathString.slice(branch.name.length + 1);
} else {
// let's switch to the default branch and clear the path,
// since we don't know how to parse the path segments
branchName = repoInfo.data.default_branch;
path = "";
}
Expand Down
16 changes: 10 additions & 6 deletions ghapi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,16 @@ export const getBranches: QueryFunction<
> = async (ctx) => {
let params = ctx.queryKey[1];
const { owner, repo } = params;
let meta = ctx.meta as BlocksQueryMeta;

const url = `repos/${owner}/${repo}/branches`;

const res = await meta.ghapi(url);
return res.data;
let octokit = ctx.meta.octokit as Octokit;
const branchesRes = await octokit.paginate(
"GET /repos/{owner}/{repo}/branches",
{
owner,
repo,
per_page: 100,
}
);
return branchesRes;
};

export interface CreateBranchParams {
Expand Down

0 comments on commit d1ad528

Please sign in to comment.