mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-29 13:03:42 +01:00
git api
This commit is contained in:
@@ -8,6 +8,26 @@
|
||||
import { Model } from '../model';
|
||||
import { GitExtension } from './git';
|
||||
import { Api } from './api';
|
||||
import { Event, SourceControlInputBox, Uri } from 'vscode';
|
||||
import { mapEvent } from '../util';
|
||||
import { Repository } from '../repository';
|
||||
|
||||
class ApiInputBox implements GitExtension.InputBox {
|
||||
set value(value: string) { this._inputBox.value = value; }
|
||||
get value(): string { return this._inputBox.value; }
|
||||
constructor(private _inputBox: SourceControlInputBox) { }
|
||||
}
|
||||
|
||||
export class ApiRepository implements GitExtension.Repository {
|
||||
|
||||
readonly rootUri: Uri;
|
||||
readonly inputBox: GitExtension.InputBox;
|
||||
|
||||
constructor(_repository: Repository) {
|
||||
this.rootUri = Uri.file(_repository.root);
|
||||
this.inputBox = new ApiInputBox(_repository.inputBox);
|
||||
}
|
||||
}
|
||||
|
||||
@Api('0.1.0')
|
||||
export class ApiImpl implements GitExtension.API {
|
||||
@@ -16,5 +36,13 @@ export class ApiImpl implements GitExtension.API {
|
||||
return this._model.git.path;
|
||||
}
|
||||
|
||||
get onDidOpenRepository(): Event<GitExtension.Repository> {
|
||||
return mapEvent(this._model.onDidOpenRepository, r => new ApiRepository(r));
|
||||
}
|
||||
|
||||
get onDidCloseRepository(): Event<GitExtension.Repository> {
|
||||
return mapEvent(this._model.onDidCloseRepository, r => new ApiRepository(r));
|
||||
}
|
||||
|
||||
constructor(private _model: Model) { }
|
||||
}
|
||||
|
||||
@@ -6,27 +6,9 @@
|
||||
'use strict';
|
||||
|
||||
import { Model } from '../model';
|
||||
import { Repository as ModelRepository } from '../repository';
|
||||
import { Uri, SourceControlInputBox } from 'vscode';
|
||||
import { GitExtension } from './git';
|
||||
import { getAPI, deprecated } from './api';
|
||||
|
||||
class InputBoxImpl implements GitExtension.InputBox {
|
||||
set value(value: string) { this.inputBox.value = value; }
|
||||
get value(): string { return this.inputBox.value; }
|
||||
constructor(private inputBox: SourceControlInputBox) { }
|
||||
}
|
||||
|
||||
class RepositoryImpl implements GitExtension.Repository {
|
||||
|
||||
readonly rootUri: Uri;
|
||||
readonly inputBox: GitExtension.InputBox;
|
||||
|
||||
constructor(repository: ModelRepository) {
|
||||
this.rootUri = Uri.file(repository.root);
|
||||
this.inputBox = new InputBoxImpl(repository.inputBox);
|
||||
}
|
||||
}
|
||||
import { ApiRepository } from './api0';
|
||||
|
||||
class NoModelGitExtension implements GitExtension {
|
||||
|
||||
@@ -56,7 +38,7 @@ class GitExtensionImpl implements GitExtension {
|
||||
|
||||
@deprecated
|
||||
async getRepositories(): Promise<GitExtension.Repository[]> {
|
||||
return this._model.repositories.map(repository => new RepositoryImpl(repository));
|
||||
return this._model.repositories.map(repository => new ApiRepository(repository));
|
||||
}
|
||||
|
||||
getAPI(range: string): GitExtension.API {
|
||||
|
||||
6
extensions/git/src/api/git.d.ts
vendored
6
extensions/git/src/api/git.d.ts
vendored
@@ -3,15 +3,16 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Uri, SourceControlInputBox } from 'vscode';
|
||||
import { Uri, SourceControlInputBox, Event } from 'vscode';
|
||||
|
||||
declare module GitExtension {
|
||||
|
||||
export interface API {
|
||||
readonly gitPath: string;
|
||||
readonly onDidOpenRepository: Event<Repository>;
|
||||
readonly onDidCloseRepository: Event<Repository>;
|
||||
}
|
||||
|
||||
//#region Deprecated API
|
||||
export interface InputBox {
|
||||
value: string;
|
||||
}
|
||||
@@ -20,7 +21,6 @@ declare module GitExtension {
|
||||
readonly rootUri: Uri;
|
||||
readonly inputBox: InputBox;
|
||||
}
|
||||
//#endregion
|
||||
}
|
||||
|
||||
export interface GitExtension {
|
||||
|
||||
Reference in New Issue
Block a user