mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-10 07:28:36 +02:00
fix: fix error message when repository is not found
This commit is contained in:
@@ -55,28 +55,35 @@ export class GitHubRepository {
|
|||||||
) {
|
) {
|
||||||
// get the list of repo from github
|
// get the list of repo from github
|
||||||
const octokit = new Octokit({ auth: opt.accessToken });
|
const octokit = new Octokit({ auth: opt.accessToken });
|
||||||
const branches = (
|
try {
|
||||||
await octokit.paginate(octokit.repos.listBranches, {
|
const branches = (
|
||||||
owner: this.owner,
|
await octokit.paginate(octokit.repos.listBranches, {
|
||||||
repo: this.repo,
|
owner: this.owner,
|
||||||
per_page: 100,
|
repo: this.repo,
|
||||||
})
|
per_page: 100,
|
||||||
).map((b) => {
|
})
|
||||||
return {
|
).map((b) => {
|
||||||
name: b.name,
|
return {
|
||||||
commit: b.commit.sha,
|
name: b.name,
|
||||||
readme: this._data.branches?.filter(
|
commit: b.commit.sha,
|
||||||
(f: Branch) => f.name == b.name
|
readme: this._data.branches?.filter(
|
||||||
)[0]?.readme,
|
(f: Branch) => f.name == b.name
|
||||||
} as Branch;
|
)[0]?.readme,
|
||||||
});
|
} as Branch;
|
||||||
this._data.branches = branches;
|
});
|
||||||
|
this._data.branches = branches;
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
await RepositoryModel.updateOne(
|
await RepositoryModel.updateOne(
|
||||||
{ externalId: this.id },
|
{ externalId: this.id },
|
||||||
{ $set: { branches } }
|
{ $set: { branches } }
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
throw new AnonymousError("repo_not_found", {
|
||||||
|
httpStatus: (error as any).status,
|
||||||
|
cause: error as Error,
|
||||||
|
object: this,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (isConnected) {
|
} else if (isConnected) {
|
||||||
const q = await RepositoryModel.findOne({ externalId: this.id }).select(
|
const q = await RepositoryModel.findOne({ externalId: this.id }).select(
|
||||||
|
|||||||
Reference in New Issue
Block a user