🐛 correctly handle remotes not found

This commit is contained in:
Nate Sesti 2024-04-14 15:29:18 -07:00
parent 36a0800677
commit 332c69fc1e
2 changed files with 8 additions and 3 deletions

View file

@ -72,7 +72,9 @@ export class CodebaseIndexer {
// Wait until Git Extension has loaded to report progress
// so we don't appear stuck at 0% while waiting
await this.ide.getRepoName(workspaceDirs[0]);
if (workspaceDirs.length > 0) {
await this.ide.getRepoName(workspaceDirs[0]);
}
yield {
progress: 0,
desc: "Starting indexing...",

View file

@ -30,9 +30,12 @@ class VsCodeIde implements IDE {
async getRepoName(dir: string): Promise<string | undefined> {
const repo = await this.getRepo(vscode.Uri.file(dir));
const remotes = repo?.repository?.remotes;
if (!remotes) {
return undefined;
}
const remote =
repo?.repository.remotes.find((r: any) => r.name === "origin") ??
repo?.repository.remotes[0];
remotes?.find((r: any) => r.name === "origin") ?? remotes?.[0];
if (!remote) {
return undefined;
}