in app/lib/server/githubTokenService.ts [121:166]
static async getRepositoryInfo(
token: string,
repositoryUrl: string
): Promise<{
clone_url: string;
ssh_url: string;
private: boolean;
full_name: string;
} | null> {
try {
const repoMatch = repositoryUrl.match(
/github\.com[\/:]([^\/]+)\/([^\/\.]+)/
);
if (!repoMatch) {
return null;
}
const [, owner, repo] = repoMatch;
const response = await fetch(
`${this.GITHUB_API_BASE}/repos/${owner}/${repo}`,
{
headers: {
Authorization: `Bearer ${token}`,
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28",
},
}
);
if (response.ok) {
const repoData = await response.json();
return {
clone_url: repoData.clone_url,
ssh_url: repoData.ssh_url,
private: repoData.private,
full_name: repoData.full_name,
};
}
return null;
} catch (error) {
console.error("Error getting repository info:", error);
return null;
}
}