mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-29 13:03:42 +01:00
@@ -5,7 +5,7 @@
|
||||
|
||||
import { Model } from '../model';
|
||||
import { Repository as BaseRepository, Resource } from '../repository';
|
||||
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, Ref, Submodule, Commit, Change, RepositoryUIState } from './git';
|
||||
import { InputBox, Git, API, Repository, Remote, RepositoryState, Branch, Ref, Submodule, Commit, Change, RepositoryUIState, Status } from './git';
|
||||
import { Event, SourceControlInputBox, Uri, SourceControl } from 'vscode';
|
||||
import { mapEvent } from '../util';
|
||||
|
||||
@@ -17,7 +17,23 @@ class ApiInputBox implements InputBox {
|
||||
|
||||
export class ApiChange implements Change {
|
||||
|
||||
constructor(_resource: Resource) { }
|
||||
constructor(private readonly resource: Resource) { }
|
||||
|
||||
public get resourceUri(): Uri {
|
||||
return this.resource.resourceUri;
|
||||
}
|
||||
|
||||
public get status(): Status {
|
||||
return this.resource.type;
|
||||
}
|
||||
|
||||
public get original(): Uri {
|
||||
return this.resource.original;
|
||||
}
|
||||
|
||||
public get renameResourceUri(): Uri | undefined {
|
||||
return this.resource.renameResourceUri;
|
||||
}
|
||||
}
|
||||
|
||||
export class ApiRepositoryState implements RepositoryState {
|
||||
@@ -79,6 +95,14 @@ export class ApiRepository implements Repository {
|
||||
return this._repository.getObjectDetails(treeish, path);
|
||||
}
|
||||
|
||||
detectObjectType(object: string): Promise<{ mimetype: string, encoding?: string }> {
|
||||
return this._repository.detectObjectType(object);
|
||||
}
|
||||
|
||||
buffer(ref: string, filePath: string): Promise<Buffer> {
|
||||
return this._repository.buffer(ref, filePath);
|
||||
}
|
||||
|
||||
diffWithHEAD(path: string): Promise<string> {
|
||||
return this._repository.diffWithHEAD(path);
|
||||
}
|
||||
@@ -150,6 +174,10 @@ export class ApiRepository implements Repository {
|
||||
pull(): Promise<void> {
|
||||
return this._repository.pull();
|
||||
}
|
||||
|
||||
clean(filePaths: string[]) {
|
||||
return this._repository.clean(filePaths.map(p => Uri.file(p)));
|
||||
}
|
||||
}
|
||||
|
||||
export class ApiGit implements Git {
|
||||
|
||||
30
extensions/git/src/api/git.d.ts
vendored
30
extensions/git/src/api/git.d.ts
vendored
@@ -56,8 +56,32 @@ export interface Remote {
|
||||
readonly isReadOnly: boolean;
|
||||
}
|
||||
|
||||
export const enum Status {
|
||||
INDEX_MODIFIED,
|
||||
INDEX_ADDED,
|
||||
INDEX_DELETED,
|
||||
INDEX_RENAMED,
|
||||
INDEX_COPIED,
|
||||
|
||||
MODIFIED,
|
||||
DELETED,
|
||||
UNTRACKED,
|
||||
IGNORED,
|
||||
|
||||
ADDED_BY_US,
|
||||
ADDED_BY_THEM,
|
||||
DELETED_BY_US,
|
||||
DELETED_BY_THEM,
|
||||
BOTH_ADDED,
|
||||
BOTH_DELETED,
|
||||
BOTH_MODIFIED
|
||||
}
|
||||
|
||||
export interface Change {
|
||||
// TODO
|
||||
readonly resourceUri: Uri;
|
||||
readonly status: Status;
|
||||
readonly original: Uri;
|
||||
readonly renameResourceUri: Uri | undefined;
|
||||
}
|
||||
|
||||
export interface RepositoryState {
|
||||
@@ -93,6 +117,8 @@ export interface Repository {
|
||||
show(ref: string, path: string): Promise<string>;
|
||||
getCommit(ref: string): Promise<Commit>;
|
||||
getObjectDetails(treeish: string, path: string): Promise<{ mode: string, object: string, size: number }>;
|
||||
detectObjectType(object: string): Promise<{ mimetype: string, encoding?: string }>;
|
||||
buffer(ref: string, filePath: string): Promise<Buffer>;
|
||||
|
||||
diffWithHEAD(path: string): Promise<string>;
|
||||
diffWith(ref: string, path: string): Promise<string>;
|
||||
@@ -118,6 +144,8 @@ export interface Repository {
|
||||
|
||||
fetch(remote?: string, ref?: string): Promise<void>;
|
||||
pull(): Promise<void>;
|
||||
|
||||
clean(filePaths: string[]): Promise<void>;
|
||||
}
|
||||
|
||||
export interface API {
|
||||
|
||||
Reference in New Issue
Block a user