add: fetch gh branches
This commit is contained in:
parent
f57e0eed3c
commit
d6ba4e7c5a
|
@ -46,3 +46,16 @@ export async function getUserRepository(userId: string, username: string): Promi
|
||||||
|
|
||||||
return repositories.repositories as GithubRepository[];
|
return repositories.repositories as GithubRepository[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getRepositoryBranches(userId: string, username: string, repository: string): Promise<string[]> {
|
||||||
|
const branches = await fetch(`https://api.github.com/repos/${username}/${repository}/branches`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${await getInstallationAccessToken(userId, username)}`,
|
||||||
|
Accept: "application/vnd.github+json",
|
||||||
|
"X-GitHub-Api-Version": "2022-11-28",
|
||||||
|
},
|
||||||
|
method: 'GET',
|
||||||
|
}).then(res => res.json());
|
||||||
|
|
||||||
|
return branches.map((branch: { name: string }) => branch.name) as string[];
|
||||||
|
}
|
Loading…
Reference in New Issue