mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-01 14:01:38 +01:00
Allow git clone command to also always use the cache (#274354)
* Allow git clone command to also always use the cache * Fix redundant checks
This commit is contained in:
@@ -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<string | undefined> {
|
||||
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<string | undefined> {
|
||||
if (!parentPath) {
|
||||
const config = workspace.getConfiguration('git');
|
||||
let defaultCloneDirectory = config.get<string>('defaultCloneDirectory') || os.homedir();
|
||||
|
||||
@@ -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()})`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user