git api: expose repositories

This commit is contained in:
Joao Moreno
2018-08-22 11:25:42 +02:00
parent cc5e8c15bf
commit ec1c4aeaf5
2 changed files with 27 additions and 3 deletions

View File

@@ -44,5 +44,9 @@ export class ApiImpl implements GitExtension.API {
return mapEvent(this._model.onDidCloseRepository, r => new ApiRepository(r));
}
get repositories(): GitExtension.Repository[] {
return this._model.repositories.map(r => new ApiRepository(r));
}
constructor(private _model: Model) { }
}

View File

@@ -9,6 +9,7 @@ declare module GitExtension {
export interface API {
readonly gitPath: string;
readonly repositories: Repository[];
readonly onDidOpenRepository: Event<Repository>;
readonly onDidCloseRepository: Event<Repository>;
}
@@ -24,8 +25,27 @@ declare module GitExtension {
}
export interface GitExtension {
getRepositories(): Promise<GitExtension.Repository[]>;
getGitPath(): Promise<string>;
// export const availableVersions: string[];
/**
* Returns the latest available API compatible with the
* provided version range.
*
* @param range Semver version range for API compatibility.
* @returns API instance
*/
getAPI(range: string): GitExtension.API;
/**
* Returns the collection of active repositories.
*
* @deprecated Use `API.repositories` instead.
*/
getRepositories(): Promise<GitExtension.Repository[]>;
/**
* Returns the path to the current git executable.
*
* @deprecated Use `API.gitPath` instead.
*/
getGitPath(): Promise<string>;
}