-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathgit.ts
More file actions
62 lines (51 loc) · 1.3 KB
/
git.ts
File metadata and controls
62 lines (51 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import * as vscode from "vscode";
export const enum RefType {
Head,
RemoteHead,
Tag
}
export interface Ref {
readonly type: RefType;
readonly name?: string;
readonly commit?: string;
readonly remote?: string;
}
export interface RepositoryState {
readonly HEAD: Ref | undefined;
readonly refs: Ref[];
}
export interface LogOptions {
/** Max number of log entries to retrieve. If not specified, the default is 32. */
readonly maxEntries?: number;
readonly path?: string;
}
export interface Commit {
readonly hash: string;
readonly message: string;
readonly parents: string[];
readonly authorDate?: Date;
readonly authorName?: string;
readonly authorEmail?: string;
readonly commitDate?: Date;
}
export interface Repository {
readonly state: RepositoryState;
log(options?: LogOptions): Promise<Commit[]>;
}
interface GitAPI {
toGitUri(uri: vscode.Uri, ref: string): vscode.Uri;
getRepository(uri: vscode.Uri): Repository | null;
}
export let api: GitAPI;
export async function initializeGitApi() {
const extension = vscode.extensions.getExtension("vscode.git");
if (!extension) {
return;
}
if (!extension.isActive) {
await extension.activate();
}
api = extension.exports.getAPI(1);
}