mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 01:58:53 +01:00
git api: deprecation
This commit is contained in:
@@ -9,7 +9,7 @@ import { Model } from '../model';
|
||||
import { Repository as ModelRepository } from '../repository';
|
||||
import { Uri, SourceControlInputBox } from 'vscode';
|
||||
import { GitExtension } from './git';
|
||||
import { getAPI } from './api';
|
||||
import { getAPI, deprecated } from './api';
|
||||
|
||||
class InputBoxImpl implements GitExtension.InputBox {
|
||||
set value(value: string) { this.inputBox.value = value; }
|
||||
@@ -28,18 +28,46 @@ class RepositoryImpl implements GitExtension.Repository {
|
||||
}
|
||||
}
|
||||
|
||||
export function createGitExtension(model?: Model): GitExtension {
|
||||
if (!model) {
|
||||
return {
|
||||
getGitPath() { throw new Error('Git model not found'); },
|
||||
getRepositories() { throw new Error('Git model not found'); },
|
||||
getAPI() { throw new Error('Git model not found'); }
|
||||
};
|
||||
class NoModelGitExtension implements GitExtension {
|
||||
|
||||
@deprecated
|
||||
async getGitPath(): Promise<string> {
|
||||
throw new Error('Git model not found');
|
||||
}
|
||||
|
||||
return {
|
||||
async getGitPath() { return model.git.path; },
|
||||
async getRepositories() { return model.repositories.map(repository => new RepositoryImpl(repository)); },
|
||||
getAPI(range: string) { return getAPI(model, range); }
|
||||
};
|
||||
@deprecated
|
||||
async getRepositories(): Promise<GitExtension.Repository[]> {
|
||||
throw new Error('Git model not found');
|
||||
}
|
||||
|
||||
getAPI(): GitExtension.API {
|
||||
throw new Error('Git model not found');
|
||||
}
|
||||
}
|
||||
|
||||
class GitExtensionImpl implements GitExtension {
|
||||
|
||||
constructor(private _model: Model) { }
|
||||
|
||||
@deprecated
|
||||
async getGitPath(): Promise<string> {
|
||||
return this._model.git.path;
|
||||
}
|
||||
|
||||
@deprecated
|
||||
async getRepositories(): Promise<GitExtension.Repository[]> {
|
||||
return this._model.repositories.map(repository => new RepositoryImpl(repository));
|
||||
}
|
||||
|
||||
getAPI(range: string): GitExtension.API {
|
||||
return getAPI(this._model, range);
|
||||
}
|
||||
}
|
||||
|
||||
export function createGitExtension(model?: Model): GitExtension {
|
||||
if (!model) {
|
||||
return new NoModelGitExtension();
|
||||
}
|
||||
|
||||
return new GitExtensionImpl(model);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user