fix(git): harden nested repository discovery

- discard an in-flight discovery when the runtime switches, mirroring the
  isRequestCurrent pattern, so a late completion cannot repopulate the
  cleared map and suppress a fresh scan
- treat a 501 from /api/fs/git-dirs as an explicit 'unsupported' marker
  instead of a generic failure; the VS Code webview now answers the route
  with unsupportedWebRouteResponse so non-repo roots show the honest
  not-a-repository state without a futile Retry
This commit is contained in:
jaygupta17
2026-08-25 19:15:35 +05:30
parent f56b934dc9
commit 5e3f9d1ba2
4 changed files with 97 additions and 9 deletions
+10
View File
@@ -116,8 +116,18 @@ export async function checkIsGitRepository(directory: string): Promise<boolean>
}
}
export class GitDirectoriesUnsupportedError extends Error {
constructor() {
super('Nested git repository discovery is not supported by this runtime');
this.name = 'GitDirectoriesUnsupportedError';
}
}
export async function listGitDirectories(root: string): Promise<string[]> {
const response = await runtimeFetch('/api/fs/git-dirs', { query: { path: root } });
if (response.status === 501) {
throw new GitDirectoriesUnsupportedError();
}
if (!response.ok) {
throw new Error(`Failed to list git directories: ${response.statusText}`);
}