mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
Update git clone to use new repo cache (#272276)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import { Model } from '../model';
|
||||
import { Repository as BaseRepository, Resource } from '../repository';
|
||||
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, ForcePushMode, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent, FetchOptions, RemoteSourceProvider, RemoteSourcePublisher, PostCommitCommandsProvider, RefQuery, BranchProtectionProvider, InitOptions, SourceControlHistoryItemDetailsProvider, GitErrorCodes } from './git';
|
||||
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, ForcePushMode, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent, FetchOptions, RemoteSourceProvider, RemoteSourcePublisher, PostCommitCommandsProvider, RefQuery, BranchProtectionProvider, InitOptions, SourceControlHistoryItemDetailsProvider, GitErrorCodes, CloneOptions } from './git';
|
||||
import { Event, SourceControlInputBox, Uri, SourceControl, Disposable, commands, CancellationToken } from 'vscode';
|
||||
import { combinedDisposable, filterEvent, mapEvent } from '../util';
|
||||
import { toGitUri } from '../uri';
|
||||
@@ -399,6 +399,12 @@ export class ApiImpl implements API {
|
||||
return this.getRepository(root) || null;
|
||||
}
|
||||
|
||||
async clone(uri: Uri, options?: CloneOptions): Promise<Uri | null> {
|
||||
const parentPath = options?.parentPath?.fsPath;
|
||||
const result = await this.#model.clone(uri.toString(), { parentPath, recursive: options?.recursive, ref: options?.ref, postCloneAction: options?.postCloneAction, skipCache: options?.skipCache });
|
||||
return result ? Uri.file(result) : null;
|
||||
}
|
||||
|
||||
async openRepository(root: Uri): Promise<Repository | null> {
|
||||
if (root.scheme !== 'file') {
|
||||
return null;
|
||||
|
||||
20
extensions/git/src/api/git.d.ts
vendored
20
extensions/git/src/api/git.d.ts
vendored
@@ -183,6 +183,20 @@ export interface InitOptions {
|
||||
defaultBranch?: string;
|
||||
}
|
||||
|
||||
export interface CloneOptions {
|
||||
parentPath?: Uri;
|
||||
/**
|
||||
* ref is only used if the repository cache is missed.
|
||||
*/
|
||||
ref?: string;
|
||||
recursive?: boolean;
|
||||
/**
|
||||
* If no postCloneAction is provided, then the users setting for git.openAfterClone is used.
|
||||
*/
|
||||
postCloneAction?: 'none' | 'open' | 'prompt';
|
||||
skipCache?: boolean;
|
||||
}
|
||||
|
||||
export interface RefQuery {
|
||||
readonly contains?: string;
|
||||
readonly count?: number;
|
||||
@@ -366,7 +380,11 @@ export interface API {
|
||||
getRepository(uri: Uri): Repository | null;
|
||||
getRepositoryRoot(uri: Uri): Promise<Uri | null>;
|
||||
init(root: Uri, options?: InitOptions): Promise<Repository | null>;
|
||||
openRepository(root: Uri): Promise<Repository | null>
|
||||
/**
|
||||
* @returns The URI of either the cloned repository, or the workspace file or folder which contains the cloned repository.
|
||||
*/
|
||||
clone(uri: Uri, options?: CloneOptions): Promise<Uri | null>;
|
||||
openRepository(root: Uri): Promise<Repository | null>;
|
||||
|
||||
registerRemoteSourcePublisher(publisher: RemoteSourcePublisher): Disposable;
|
||||
registerRemoteSourceProvider(provider: RemoteSourceProvider): Disposable;
|
||||
|
||||
Reference in New Issue
Block a user