Add git clone for project to Open Existing dialog (#15244)

* expose git clone api

* add git clone option for projects in open existing dialog

* add sql carbon edits

* cleanup and error handling

* fix telemetry property

* addressing comments

* add gitignore

* copy git.d.ts from git extension

* remove copy of git.d.ts from data-workspace extension

* use single quotes

* Remove git copy from git clone PR (#15286)

* Remove copy git typings

* Remove gitignore

* update error messages

* lowercase

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
This commit is contained in:
Kim Santiago
2021-04-30 08:12:22 -10:00
committed by GitHub
parent f2ee8b11b4
commit 25681defd8
8 changed files with 120 additions and 34 deletions

View File

@@ -5,8 +5,8 @@
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, RemoteSourceProvider, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent } from './git';
import { Event, SourceControlInputBox, Uri, SourceControl, Disposable, commands } from 'vscode';
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, ForcePushMode, Ref, Submodule, Commit, Change, RepositoryUIState, Status, LogOptions, APIState, CommitOptions, RefType, RemoteSourceProvider, CredentialsProvider, BranchQuery, PushErrorHandler, PublishEvent, ICloneOptions } from './git'; // {{SQL CARBON EDIT}} add ICloneOptions
import { Event, SourceControlInputBox, Uri, SourceControl, Disposable, commands, CancellationToken } from 'vscode'; // {{SQL CARBON EDIT}} add CancellationToken
import { mapEvent } from '../util';
import { toGitUri } from '../uri';
import { pickRemoteSource, PickRemoteSourceOptions } from '../remoteSource';
@@ -253,6 +253,11 @@ export class ApiImpl implements API {
return this._model.repositories.map(r => new ApiRepository(r));
}
// {{SQL CARBON EDIT}}
async clone(url: string, options: ICloneOptions, cancellationToken?: CancellationToken): Promise<string> {
return this._model.git.clone(url, options, cancellationToken);
}
toGitUri(uri: Uri, ref: string): Uri {
return toGitUri(uri, ref);
}

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Uri, Event, Disposable, ProviderResult } from 'vscode';
import { Uri, Event, Disposable, ProviderResult, CancellationToken, Progress } from 'vscode'; // {{SQL CARBON EDIT}} add CancellationToken
export { ProviderResult } from 'vscode';
export interface Git {
@@ -251,6 +251,14 @@ export interface API {
readonly onDidOpenRepository: Event<Repository>;
readonly onDidCloseRepository: Event<Repository>;
/**
* clones the repository at the specified url locally
* @param url url of repository to clone
* @param options
* @param cancellationToken
* @returns a promise to the string location where the repository was cloned to
*/
clone(url: string, options: ICloneOptions, cancellationToken?: CancellationToken): Promise<string>; // {{SQL CARBON EDIT}}
toGitUri(uri: Uri, ref: string): Uri;
getRepository(uri: Uri): Repository | null;
init(root: Uri): Promise<Repository | null>;
@@ -316,3 +324,10 @@ export const enum GitErrorCodes {
NoPathFound = 'NoPathFound',
UnknownPath = 'UnknownPath',
}
// {{SQL CARBON EDIT}} move ICloneOptions from git.ts to here since it's used in clone()
export interface ICloneOptions {
readonly parentPath: string;
readonly progress: Progress<{ increment: number }>;
readonly recursive?: boolean;
}