| 1 | // The parts of VS Code's built-in Git extensions' APIs this extension uses (vscode.git and vscode.git-base, |
| 2 | // version 1). Declared here rather than copied whole: only these members are relied on. |
| 3 | import type { Disposable, Event, ProviderResult, Uri } from "vscode"; |
| 4 | |
| 5 | export interface RemoteSource { |
| 6 | readonly name: string; |
| 7 | readonly description?: string; |
| 8 | readonly detail?: string; |
| 9 | /** Codicon name. */ |
| 10 | readonly icon?: string; |
| 11 | readonly url: string | string[]; |
| 12 | } |
| 13 | |
| 14 | export interface RemoteSourceAction { |
| 15 | readonly label: string; |
| 16 | /** Codicon name. */ |
| 17 | readonly icon: string; |
| 18 | run(branch: string): void; |
| 19 | } |
| 20 | |
| 21 | export interface RemoteSourceProvider { |
| 22 | readonly name: string; |
| 23 | /** Codicon name. */ |
| 24 | readonly icon?: string; |
| 25 | readonly label?: string; |
| 26 | readonly placeholder?: string; |
| 27 | readonly supportsQuery?: boolean; |
| 28 | getBranches?(url: string): ProviderResult<string[]>; |
| 29 | getRemoteSourceActions?(url: string): ProviderResult<RemoteSourceAction[]>; |
| 30 | getRemoteSources(query?: string): ProviderResult<RemoteSource[]>; |
| 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; |
| 40 | readonly showRecentSources?: boolean; |
| 41 | } |
| 42 | |
| 43 | export interface GitBaseAPI { |
| 44 | registerRemoteSourceProvider(provider: RemoteSourceProvider): Disposable; |
| 45 | pickRemoteSource(options: PickRemoteSourceOptions): Promise<string | { url: string; branch?: string } | undefined>; |
| 46 | } |
| 47 | |
| 48 | export interface GitBaseExtension { |
| 49 | readonly enabled: boolean; |
| 50 | readonly onDidChangeEnablement: Event<boolean>; |
| 51 | getAPI(version: 1): GitBaseAPI; |
| 52 | } |
| 53 | |
| 54 | export interface Credentials { |
| 55 | readonly username: string; |
| 56 | readonly password: string; |
| 57 | } |
| 58 | |
| 59 | export interface CredentialsProvider { |
| 60 | getCredentials(host: Uri): ProviderResult<Credentials>; |
| 61 | } |
| 62 | |
| 63 | export interface Remote { |
| 64 | readonly name: string; |
| 65 | readonly fetchUrl?: string; |
| 66 | readonly pushUrl?: string; |
| 67 | readonly isReadOnly: boolean; |
| 68 | } |
| 69 | |
| 70 | export interface Branch { |
| 71 | readonly name?: string; |
| 72 | readonly commit?: string; |
| 73 | readonly upstream?: { readonly remote: string; readonly name: string }; |
| 74 | } |
| 75 | |
| 76 | export interface RepositoryState { |
| 77 | readonly HEAD: Branch | undefined; |
| 78 | readonly remotes: Remote[]; |
| 79 | } |
| 80 | |
| 81 | export interface Repository { |
| 82 | readonly rootUri: Uri; |
| 83 | readonly state: RepositoryState; |
| 84 | addRemote(name: string, url: string): Promise<void>; |
| 85 | push(remoteName?: string, branchName?: string, setUpstream?: boolean): Promise<void>; |
| 86 | } |
| 87 | |
| 88 | export interface RemoteSourcePublisher { |
| 89 | readonly name: string; |
| 90 | /** Codicon name. */ |
| 91 | readonly icon?: string; |
| 92 | publishRepository(repository: Repository): Promise<void>; |
| 93 | } |
| 94 | |
| 95 | export interface GitAPI { |
| 96 | readonly git: { readonly path: string }; |
| 97 | readonly repositories: Repository[]; |
| 98 | registerCredentialsProvider(provider: CredentialsProvider): Disposable; |
| 99 | registerRemoteSourcePublisher(publisher: RemoteSourcePublisher): Disposable; |
| 100 | } |
| 101 | |
| 102 | export interface GitExtension { |
| 103 | readonly enabled: boolean; |
| 104 | readonly onDidChangeEnablement: Event<boolean>; |
| 105 | getAPI(version: 1): GitAPI; |
| 106 | } |