mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
github: get all branches
This commit is contained in:
@@ -88,11 +88,25 @@ export class GithubRemoteSourceProvider implements RemoteSourceProvider {
|
||||
}
|
||||
|
||||
const octokit = await getOctokit();
|
||||
const branches = await octokit.repos.listBranches(repository);
|
||||
|
||||
const branches: string[] = [];
|
||||
let page = 1;
|
||||
|
||||
while (true) {
|
||||
let res = await octokit.repos.listBranches({ ...repository, per_page: 100, page });
|
||||
|
||||
if (res.data.length === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
branches.push(...res.data.map(b => b.name));
|
||||
page++;
|
||||
}
|
||||
|
||||
const repo = await octokit.repos.get(repository);
|
||||
const defaultBranch = repo.data.default_branch;
|
||||
|
||||
return branches.data.map(b => b.name).sort((a, b) => a === defaultBranch ? -1 : b === defaultBranch ? 1 : 0);
|
||||
return branches.sort((a, b) => a === defaultBranch ? -1 : b === defaultBranch ? 1 : 0);
|
||||
}
|
||||
|
||||
publishRepository(repository: Repository): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user