mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 22:41:31 +01:00
git api: repository state
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import { Model } from '../model';
|
||||
import { Repository as BaseRepository } from '../repository';
|
||||
import { InputBox, Git, API, Repository, Remote } from './git';
|
||||
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, Ref, Submodule, Commit } from './git';
|
||||
import { Event, SourceControlInputBox, Uri } from 'vscode';
|
||||
import { mapEvent } from '../util';
|
||||
|
||||
@@ -17,13 +17,24 @@ class ApiInputBox implements InputBox {
|
||||
constructor(private _inputBox: SourceControlInputBox) { }
|
||||
}
|
||||
|
||||
export class ApiRepositoryState implements RepositoryState {
|
||||
|
||||
get HEAD(): Branch | undefined { return this._repository.HEAD; }
|
||||
get refs(): Ref[] { return [...this._repository.refs]; }
|
||||
get remotes(): Remote[] { return [...this._repository.remotes]; }
|
||||
get submodules(): Submodule[] { return [...this._repository.submodules]; }
|
||||
get rebaseCommit(): Commit | undefined { return this._repository.rebaseCommit; }
|
||||
|
||||
readonly onDidChange: Event<void> = this._repository.onDidRunGitStatus;
|
||||
|
||||
constructor(private _repository: BaseRepository) { }
|
||||
}
|
||||
|
||||
export class ApiRepository implements Repository {
|
||||
|
||||
readonly rootUri: Uri = Uri.file(this._repository.root);
|
||||
readonly inputBox: InputBox = new ApiInputBox(this._repository.inputBox);
|
||||
get remotes(): Remote[] { return [...this._repository.remotes]; }
|
||||
|
||||
readonly onDidRunGitStatus: Event<void> = this._repository.onDidRunGitStatus;
|
||||
readonly state: RepositoryState = new ApiRepositoryState(this._repository);
|
||||
|
||||
constructor(private _repository: BaseRepository) { }
|
||||
|
||||
|
||||
49
extensions/git/src/api/git.d.ts
vendored
49
extensions/git/src/api/git.d.ts
vendored
@@ -14,6 +14,42 @@ export interface InputBox {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export const enum RefType {
|
||||
Head,
|
||||
RemoteHead,
|
||||
Tag
|
||||
}
|
||||
|
||||
export interface Ref {
|
||||
readonly type: RefType;
|
||||
readonly name?: string;
|
||||
readonly commit?: string;
|
||||
readonly remote?: string;
|
||||
}
|
||||
|
||||
export interface UpstreamRef {
|
||||
readonly remote: string;
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
export interface Branch extends Ref {
|
||||
readonly upstream?: UpstreamRef;
|
||||
readonly ahead?: number;
|
||||
readonly behind?: number;
|
||||
}
|
||||
|
||||
export interface Commit {
|
||||
readonly hash: string;
|
||||
readonly message: string;
|
||||
readonly parents: string[];
|
||||
}
|
||||
|
||||
export interface Submodule {
|
||||
readonly name: string;
|
||||
readonly path: string;
|
||||
readonly url: string;
|
||||
}
|
||||
|
||||
export interface Remote {
|
||||
readonly name: string;
|
||||
readonly fetchUrl?: string;
|
||||
@@ -21,12 +57,19 @@ export interface Remote {
|
||||
readonly isReadOnly: boolean;
|
||||
}
|
||||
|
||||
export interface RepositoryState {
|
||||
readonly HEAD: Branch | undefined;
|
||||
readonly refs: Ref[];
|
||||
readonly remotes: Remote[];
|
||||
readonly submodules: Submodule[];
|
||||
readonly rebaseCommit: Commit | undefined;
|
||||
readonly onDidChange: Event<void>;
|
||||
}
|
||||
|
||||
export interface Repository {
|
||||
readonly rootUri: Uri;
|
||||
readonly inputBox: InputBox;
|
||||
readonly remotes: Remote[];
|
||||
|
||||
readonly onDidRunGitStatus: Event<void>;
|
||||
readonly state: RepositoryState;
|
||||
|
||||
status(): Promise<void>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user