mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 20:13:32 +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();
|
||||
|
||||
Reference in New Issue
Block a user