fix mulitple bugs

This commit is contained in:
tdurieux
2026-05-05 12:34:03 +03:00
parent 7384638993
commit 27d6b56da7
13 changed files with 242 additions and 29 deletions
+29 -6
View File
@@ -55,12 +55,35 @@ export class GitHubRepository {
}
) {
const oct = octokit(opt.accessToken);
const commit = await oct.repos.getCommit({
owner: this.owner,
repo: this.repo,
ref: sha,
});
return commit.data;
try {
const commit = await oct.repos.getCommit({
owner: this.owner,
repo: this.repo,
ref: sha,
});
return commit.data;
} catch (error) {
const status = (error as { status?: number }).status;
if (status === 404) {
// Distinguish: does the repo itself still exist?
let repoExists = false;
try {
await oct.repos.get({ owner: this.owner, repo: this.repo });
repoExists = true;
} catch {
repoExists = false;
}
throw new AnonymousError(
repoExists ? "commit_not_found" : "repo_not_found",
{
httpStatus: 404,
cause: error as Error,
object: this,
}
);
}
throw error;
}
}
async branches(opt: {