MCPcopy Create free account
hub / github.com/continuedev/continue / getRepo

Method getRepo

extensions/vscode/src/util/ideUtils.ts:545–584  ·  view source on GitHub ↗
(forDirectory: vscode.Uri)

Source from the content-addressed store, hash-verified

543 private static secondsToWaitForGitToLoad =
544 process.env.NODE_ENV === "test" ? 1 : 20;
545 async getRepo(forDirectory: vscode.Uri): Promise<Repository | undefined> {
546 const workspaceDirs = this.getWorkspaceDirectories().map((dir) =>
547 dir.toString(),
548 );
549 const { foundInDir } = findUriInDirs(
550 forDirectory.toString(),
551 workspaceDirs,
552 );
553 if (foundInDir) {
554 // Check if the repository is already cached
555 const cachedRepo = this.repoCache.get(foundInDir);
556 if (cachedRepo) {
557 return cachedRepo;
558 }
559 }
560
561 let repo = await this._getRepo(forDirectory);
562
563 let i = 0;
564 while (!repo?.state?.HEAD?.name) {
565 if (this._repoWasNone) {
566 return undefined;
567 }
568
569 await new Promise((resolve) => setTimeout(resolve, 1000));
570 i++;
571 if (i >= VsCodeIdeUtils.secondsToWaitForGitToLoad) {
572 this._repoWasNone = true;
573 return undefined;
574 }
575 repo = await this._getRepo(forDirectory);
576 }
577
578 if (foundInDir) {
579 // Cache the repository for the parent directory
580 this.repoCache.set(foundInDir, repo);
581 }
582
583 return repo;
584 }
585
586 async getGitRoot(forDirectory: vscode.Uri): Promise<vscode.Uri | undefined> {
587 const repo = await this.getRepo(forDirectory);

Callers 3

getGitRootMethod · 0.95
getBranchMethod · 0.95
constructorMethod · 0.45

Calls 5

_getRepoMethod · 0.95
findUriInDirsFunction · 0.90
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected