Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/git/common/gitService.ts
13401 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { CancellationToken } from '../../../../base/common/cancellation.js';
7
import { IDisposable } from '../../../../base/common/lifecycle.js';
8
import { IObservable } from '../../../../base/common/observable.js';
9
import { URI } from '../../../../base/common/uri.js';
10
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
11
12
export enum GitRefType {
13
Head,
14
RemoteHead,
15
Tag
16
}
17
18
export interface GitRef {
19
readonly type: GitRefType;
20
readonly name?: string;
21
readonly commit?: string;
22
readonly remote?: string;
23
}
24
25
export interface GitRefQuery {
26
readonly contains?: string;
27
readonly count?: number;
28
readonly pattern?: string | string[];
29
readonly sort?: 'alphabetically' | 'committerdate' | 'creatordate';
30
}
31
32
export interface GitChange {
33
readonly uri: URI;
34
readonly originalUri: URI | undefined;
35
readonly modifiedUri: URI | undefined;
36
}
37
38
export interface GitDiffChange extends GitChange {
39
readonly insertions: number;
40
readonly deletions: number;
41
}
42
43
export interface GitRemote {
44
readonly name: string;
45
readonly fetchUrl?: string;
46
readonly pushUrl?: string;
47
readonly isReadOnly: boolean;
48
}
49
50
export interface GitRepositoryState {
51
readonly HEAD?: GitBranch;
52
readonly remotes: readonly GitRemote[];
53
readonly mergeChanges: readonly GitChange[];
54
readonly indexChanges: readonly GitChange[];
55
readonly workingTreeChanges: readonly GitChange[];
56
readonly untrackedChanges: readonly GitChange[];
57
}
58
59
export interface GitBranch extends GitRef {
60
readonly upstream?: GitUpstreamRef;
61
readonly ahead?: number;
62
readonly behind?: number;
63
}
64
65
export interface GitBaseRef {
66
readonly name: string;
67
readonly isProtected: boolean;
68
}
69
70
export interface GitUpstreamRef {
71
readonly remote: string;
72
readonly name: string;
73
readonly commit?: string;
74
}
75
76
export interface IGitRepository {
77
readonly rootUri: URI;
78
79
readonly state: IObservable<GitRepositoryState>;
80
updateState(state: GitRepositoryState): void;
81
82
getRefs(query: GitRefQuery, token?: CancellationToken): Promise<GitRef[]>;
83
diffBetweenWithStats(ref1: string, ref2: string, path?: string): Promise<GitDiffChange[]>;
84
diffBetweenWithStats2(ref: string, path?: string): Promise<GitDiffChange[]>;
85
}
86
87
export interface IGitExtensionDelegate {
88
readonly repositories: Iterable<IGitRepository>;
89
openRepository(uri: URI): Promise<IGitRepository | undefined>;
90
91
getRefs(root: URI, query?: GitRefQuery, token?: CancellationToken): Promise<GitRef[]>;
92
diffBetweenWithStats(root: URI, ref1: string, ref2: string, path?: string): Promise<GitDiffChange[]>;
93
diffBetweenWithStats2(root: URI, ref: string, path?: string): Promise<GitDiffChange[]>;
94
}
95
96
export const IGitService = createDecorator<IGitService>('gitService');
97
98
export interface IGitService {
99
readonly _serviceBrand: undefined;
100
101
readonly repositories: Iterable<IGitRepository>;
102
103
setDelegate(delegate: IGitExtensionDelegate): IDisposable;
104
105
openRepository(uri: URI): Promise<IGitRepository | undefined>;
106
}
107
108