mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-07 15:26:49 +01:00
6957a5c058
fixes #50292
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
'use strict';
|
|
|
|
import { Model } from './model';
|
|
import { Repository as ModelRepository } from './repository';
|
|
import { Uri, SourceControlInputBox } from 'vscode';
|
|
|
|
export interface InputBox {
|
|
value: string;
|
|
}
|
|
|
|
export class InputBoxImpl implements InputBox {
|
|
set value(value: string) { this.inputBox.value = value; }
|
|
get value(): string { return this.inputBox.value; }
|
|
constructor(private inputBox: SourceControlInputBox) { }
|
|
}
|
|
|
|
export interface Repository {
|
|
readonly rootUri: Uri;
|
|
readonly inputBox: InputBox;
|
|
}
|
|
|
|
export class RepositoryImpl implements Repository {
|
|
|
|
readonly rootUri: Uri;
|
|
readonly inputBox: InputBox;
|
|
|
|
constructor(repository: ModelRepository) {
|
|
this.rootUri = Uri.file(repository.root);
|
|
this.inputBox = new InputBoxImpl(repository.inputBox);
|
|
}
|
|
}
|
|
|
|
export interface API {
|
|
getRepositories(): Promise<Repository[]>;
|
|
getGitPath(): Promise<string>;
|
|
}
|
|
|
|
export class APIImpl implements API {
|
|
|
|
constructor(private model: Model) { }
|
|
|
|
async getGitPath(): Promise<string> {
|
|
return this.model.git.path;
|
|
}
|
|
|
|
async getRepositories(): Promise<Repository[]> {
|
|
return this.model.repositories.map(repository => new RepositoryImpl(repository));
|
|
}
|
|
}
|
|
|
|
export class NoopAPIImpl implements API {
|
|
|
|
async getGitPath(): Promise<string> {
|
|
throw new Error('Git model not found');
|
|
}
|
|
|
|
async getRepositories(): Promise<Repository[]> {
|
|
throw new Error('Git model not found');
|
|
}
|
|
}
|