Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/git-base/src/api/git-base.d.ts
3320 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 { Command, Disposable, Event, ProviderResult } from 'vscode';
7
export { ProviderResult } from 'vscode';
8
9
export interface API {
10
registerRemoteSourceProvider(provider: RemoteSourceProvider): Disposable;
11
getRemoteSourceActions(url: string): Promise<RemoteSourceAction[]>;
12
pickRemoteSource(options: PickRemoteSourceOptions): Promise<string | PickRemoteSourceResult | undefined>;
13
}
14
15
export interface GitBaseExtension {
16
17
readonly enabled: boolean;
18
readonly onDidChangeEnablement: Event<boolean>;
19
20
/**
21
* Returns a specific API version.
22
*
23
* Throws error if git-base extension is disabled. You can listed to the
24
* [GitBaseExtension.onDidChangeEnablement](#GitBaseExtension.onDidChangeEnablement)
25
* event to know when the extension becomes enabled/disabled.
26
*
27
* @param version Version number.
28
* @returns API instance
29
*/
30
getAPI(version: 1): API;
31
}
32
33
export interface PickRemoteSourceOptions {
34
readonly providerLabel?: (provider: RemoteSourceProvider) => string;
35
readonly urlLabel?: string | ((url: string) => string);
36
readonly providerName?: string;
37
readonly title?: string;
38
readonly placeholder?: string;
39
readonly branch?: boolean; // then result is PickRemoteSourceResult
40
readonly showRecentSources?: boolean;
41
}
42
43
export interface PickRemoteSourceResult {
44
readonly url: string;
45
readonly branch?: string;
46
}
47
48
export interface RemoteSourceAction {
49
readonly label: string;
50
/**
51
* Codicon name
52
*/
53
readonly icon: string;
54
run(branch: string): void;
55
}
56
57
export interface RemoteSource {
58
readonly name: string;
59
readonly description?: string;
60
readonly detail?: string;
61
/**
62
* Codicon name
63
*/
64
readonly icon?: string;
65
readonly url: string | string[];
66
}
67
68
export interface RecentRemoteSource extends RemoteSource {
69
readonly timestamp: number;
70
}
71
72
export interface RemoteSourceProvider {
73
readonly name: string;
74
/**
75
* Codicon name
76
*/
77
readonly icon?: string;
78
readonly label?: string;
79
readonly placeholder?: string;
80
readonly supportsQuery?: boolean;
81
82
getBranches?(url: string): ProviderResult<string[]>;
83
getRemoteSourceActions?(url: string): ProviderResult<RemoteSourceAction[]>;
84
getRecentRemoteSources?(query?: string): ProviderResult<RecentRemoteSource[]>;
85
getRemoteSources(query?: string): ProviderResult<RemoteSource[]>;
86
}
87
88