in app/lib/githubAPIService.ts [138:173]
static async getRepositoryBranches(
token: string,
owner: string,
repo: string
): Promise<GitHubBranch[]> {
try {
const response = await fetch(
`${this.GITHUB_API_BASE}/repos/${owner}/${repo}/branches`,
{
headers: {
Authorization: `Bearer ${token}`,
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
}
);
if (!response.ok) {
console.error("Failed to fetch repository branches:", response.status);
return [];
}
const branches = await response.json();
return branches.map((branch: any) => ({
name: branch.name,
commit: {
sha: branch.commit.sha,
url: branch.commit.url,
},
protected: branch.protected,
}));
} catch (error) {
console.error("Error fetching repository branches:", error);
return [];
}
}