3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { Uri , Event , Disposable , ProviderResult } from 'vscode' ;
6
+ import { Uri , Event , Disposable , ProviderResult , Command } from 'vscode' ;
7
7
export { ProviderResult } from 'vscode' ;
8
8
9
9
export interface Git {
@@ -14,6 +14,11 @@ export interface InputBox {
14
14
value : string ;
15
15
}
16
16
17
+ export const enum ForcePushMode {
18
+ Force ,
19
+ ForceWithLease
20
+ }
21
+
17
22
export const enum RefType {
18
23
Head ,
19
24
RemoteHead ,
@@ -131,6 +136,24 @@ export interface CommitOptions {
131
136
signCommit ?: boolean ;
132
137
empty ?: boolean ;
133
138
noVerify ?: boolean ;
139
+ requireUserConfig ?: boolean ;
140
+ useEditor ?: boolean ;
141
+ verbose ?: boolean ;
142
+ /**
143
+ * string - execute the specified command after the commit operation
144
+ * undefined - execute the command specified in git.postCommitCommand
145
+ * after the commit operation
146
+ * null - do not execute any command after the commit operation
147
+ */
148
+ postCommitCommand ?: string | null ;
149
+ }
150
+
151
+ export interface FetchOptions {
152
+ remote ?: string ;
153
+ ref ?: string ;
154
+ all ?: boolean ;
155
+ prune ?: boolean ;
156
+ depth ?: number ;
134
157
}
135
158
136
159
export interface BranchQuery {
@@ -158,6 +181,8 @@ export interface Repository {
158
181
show ( ref : string , path : string ) : Promise < string > ;
159
182
getCommit ( ref : string ) : Promise < Commit > ;
160
183
184
+ add ( paths : string [ ] ) : Promise < void > ;
185
+ revert ( paths : string [ ] ) : Promise < void > ;
161
186
clean ( paths : string [ ] ) : Promise < void > ;
162
187
163
188
apply ( patch : string , reverse ?: boolean ) : Promise < void > ;
@@ -184,16 +209,20 @@ export interface Repository {
184
209
185
210
getMergeBase ( ref1 : string , ref2 : string ) : Promise < string > ;
186
211
212
+ tag ( name : string , upstream : string ) : Promise < void > ;
213
+ deleteTag ( name : string ) : Promise < void > ;
214
+
187
215
status ( ) : Promise < void > ;
188
216
checkout ( treeish : string ) : Promise < void > ;
189
217
190
218
addRemote ( name : string , url : string ) : Promise < void > ;
191
219
removeRemote ( name : string ) : Promise < void > ;
192
220
renameRemote ( name : string , newName : string ) : Promise < void > ;
193
221
222
+ fetch ( options ?: FetchOptions ) : Promise < void > ;
194
223
fetch ( remote ?: string , ref ?: string , depth ?: number ) : Promise < void > ;
195
224
pull ( unshallow ?: boolean ) : Promise < void > ;
196
- push ( remoteName ?: string , branchName ?: string , setUpstream ?: boolean ) : Promise < void > ;
225
+ push ( remoteName ?: string , branchName ?: string , setUpstream ?: boolean , force ?: ForcePushMode ) : Promise < void > ;
197
226
198
227
blame ( path : string ) : Promise < string > ;
199
228
log ( options ?: LogOptions ) : Promise < Commit [ ] > ;
@@ -231,15 +260,27 @@ export interface CredentialsProvider {
231
260
getCredentials ( host : Uri ) : ProviderResult < Credentials > ;
232
261
}
233
262
263
+ export type CommitCommand = Command & { description ?: string } ;
264
+
265
+ export interface PostCommitCommandsProvider {
266
+ getCommands ( repository : Repository ) : CommitCommand [ ] ;
267
+ }
268
+
234
269
export interface PushErrorHandler {
235
270
handlePushError ( repository : Repository , remote : Remote , refspec : string , error : Error & { gitErrorCode : GitErrorCodes } ) : Promise < boolean > ;
236
271
}
237
272
238
273
export type APIState = 'uninitialized' | 'initialized' ;
239
274
275
+ export interface PublishEvent {
276
+ repository : Repository ;
277
+ branch ?: string ;
278
+ }
279
+
240
280
export interface API {
241
281
readonly state : APIState ;
242
282
readonly onDidChangeState : Event < APIState > ;
283
+ readonly onDidPublish : Event < PublishEvent > ;
243
284
readonly git : Git ;
244
285
readonly repositories : Repository [ ] ;
245
286
readonly onDidOpenRepository : Event < Repository > ;
@@ -248,10 +289,12 @@ export interface API {
248
289
toGitUri ( uri : Uri , ref : string ) : Uri ;
249
290
getRepository ( uri : Uri ) : Repository | null ;
250
291
init ( root : Uri ) : Promise < Repository | null > ;
292
+ openRepository ( root : Uri ) : Promise < Repository | null >
251
293
252
294
registerRemoteSourcePublisher ( publisher : RemoteSourcePublisher ) : Disposable ;
253
295
registerRemoteSourceProvider ( provider : RemoteSourceProvider ) : Disposable ;
254
296
registerCredentialsProvider ( provider : CredentialsProvider ) : Disposable ;
297
+ registerPostCommitCommandsProvider ( provider : PostCommitCommandsProvider ) : Disposable ;
255
298
registerPushErrorHandler ( handler : PushErrorHandler ) : Disposable ;
256
299
}
257
300
@@ -263,7 +306,7 @@ export interface GitExtension {
263
306
/**
264
307
* Returns a specific API version.
265
308
*
266
- * Throws error if git extension is disabled. You can listed to the
309
+ * Throws error if git extension is disabled. You can listen to the
267
310
* [GitExtension.onDidChangeEnablement](#GitExtension.onDidChangeEnablement) event
268
311
* to know when the extension becomes enabled/disabled.
269
312
*
@@ -309,4 +352,5 @@ export const enum GitErrorCodes {
309
352
PatchDoesNotApply = 'PatchDoesNotApply' ,
310
353
NoPathFound = 'NoPathFound' ,
311
354
UnknownPath = 'UnknownPath' ,
355
+ EmptyCommitMessage = 'EmptyCommitMessage'
312
356
}
0 commit comments