diff --git a/extensions/git/src/cloneManager.ts b/extensions/git/src/cloneManager.ts index e25ee8d0df7..795901dde99 100644 --- a/extensions/git/src/cloneManager.ts +++ b/extensions/git/src/cloneManager.ts @@ -27,15 +27,7 @@ export class CloneManager { private readonly telemetryReporter: TelemetryReporter, private readonly repositoryCache: RepositoryCache) { } - clone(url?: string, options: CloneOptions = {}) { - const cachedRepository = url ? this.repositoryCache.get(url) : undefined; - if (url && cachedRepository && (cachedRepository.length > 0)) { - return this.tryOpenExistingRepository(cachedRepository, url, options.postCloneAction, options.parentPath, options.ref); - } - return this.cloneRepository(url, options.parentPath, options); - } - - private async cloneRepository(url?: string, parentPath?: string, options: { recursive?: boolean; ref?: string; postCloneAction?: ApiPostCloneAction } = {}): Promise { + async clone(url?: string, options: CloneOptions = {}) { if (!url || typeof url !== 'string') { url = await pickRemoteSource({ providerLabel: provider => l10n.t('Clone from {0}', provider.name), @@ -56,6 +48,14 @@ export class CloneManager { url = url.trim().replace(/^git\s+clone\s+/, ''); + const cachedRepository = this.repositoryCache.get(url); + if (cachedRepository && (cachedRepository.length > 0)) { + return this.tryOpenExistingRepository(cachedRepository, url, options.postCloneAction, options.parentPath, options.ref); + } + return this.cloneRepository(url, options.parentPath, options); + } + + private async cloneRepository(url: string, parentPath?: string, options: { recursive?: boolean; ref?: string; postCloneAction?: ApiPostCloneAction } = {}): Promise { if (!parentPath) { const config = workspace.getConfiguration('git'); let defaultCloneDirectory = config.get('defaultCloneDirectory') || os.homedir(); diff --git a/extensions/git/src/protocolHandler.ts b/extensions/git/src/protocolHandler.ts index 90491fecd50..42289abcb9c 100644 --- a/extensions/git/src/protocolHandler.ts +++ b/extensions/git/src/protocolHandler.ts @@ -21,6 +21,7 @@ export class GitProtocolHandler implements UriHandler { this.disposables.push(window.registerUriHandler(this)); } + // example code-oss://vscode.git/clone?url=https://github.com/microsoft/vscode handleUri(uri: Uri): void { this.logger.info(`[GitProtocolHandler][handleUri] URI:(${uri.toString()})`);