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:
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user