33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { Uri , Event , Disposable , ProviderResult } from 'vscode' ;
6+ import { Uri , Event , Disposable , ProviderResult , Command } from 'vscode' ;
77export { ProviderResult } from 'vscode' ;
88
99export interface Git {
@@ -14,6 +14,11 @@ export interface InputBox {
1414 value : string ;
1515}
1616
17+ export const enum ForcePushMode {
18+ Force ,
19+ ForceWithLease
20+ }
21+
1722export const enum RefType {
1823 Head ,
1924 RemoteHead ,
@@ -131,6 +136,24 @@ export interface CommitOptions {
131136 signCommit ?: boolean ;
132137 empty ?: boolean ;
133138 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 ;
134157}
135158
136159export interface BranchQuery {
@@ -158,6 +181,8 @@ export interface Repository {
158181 show ( ref : string , path : string ) : Promise < string > ;
159182 getCommit ( ref : string ) : Promise < Commit > ;
160183
184+ add ( paths : string [ ] ) : Promise < void > ;
185+ revert ( paths : string [ ] ) : Promise < void > ;
161186 clean ( paths : string [ ] ) : Promise < void > ;
162187
163188 apply ( patch : string , reverse ?: boolean ) : Promise < void > ;
@@ -184,16 +209,20 @@ export interface Repository {
184209
185210 getMergeBase ( ref1 : string , ref2 : string ) : Promise < string > ;
186211
212+ tag ( name : string , upstream : string ) : Promise < void > ;
213+ deleteTag ( name : string ) : Promise < void > ;
214+
187215 status ( ) : Promise < void > ;
188216 checkout ( treeish : string ) : Promise < void > ;
189217
190218 addRemote ( name : string , url : string ) : Promise < void > ;
191219 removeRemote ( name : string ) : Promise < void > ;
192220 renameRemote ( name : string , newName : string ) : Promise < void > ;
193221
222+ fetch ( options ?: FetchOptions ) : Promise < void > ;
194223 fetch ( remote ?: string , ref ?: string , depth ?: number ) : Promise < void > ;
195224 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 > ;
197226
198227 blame ( path : string ) : Promise < string > ;
199228 log ( options ?: LogOptions ) : Promise < Commit [ ] > ;
@@ -231,15 +260,27 @@ export interface CredentialsProvider {
231260 getCredentials ( host : Uri ) : ProviderResult < Credentials > ;
232261}
233262
263+ export type CommitCommand = Command & { description ?: string } ;
264+
265+ export interface PostCommitCommandsProvider {
266+ getCommands ( repository : Repository ) : CommitCommand [ ] ;
267+ }
268+
234269export interface PushErrorHandler {
235270 handlePushError ( repository : Repository , remote : Remote , refspec : string , error : Error & { gitErrorCode : GitErrorCodes } ) : Promise < boolean > ;
236271}
237272
238273export type APIState = 'uninitialized' | 'initialized' ;
239274
275+ export interface PublishEvent {
276+ repository : Repository ;
277+ branch ?: string ;
278+ }
279+
240280export interface API {
241281 readonly state : APIState ;
242282 readonly onDidChangeState : Event < APIState > ;
283+ readonly onDidPublish : Event < PublishEvent > ;
243284 readonly git : Git ;
244285 readonly repositories : Repository [ ] ;
245286 readonly onDidOpenRepository : Event < Repository > ;
@@ -248,10 +289,12 @@ export interface API {
248289 toGitUri ( uri : Uri , ref : string ) : Uri ;
249290 getRepository ( uri : Uri ) : Repository | null ;
250291 init ( root : Uri ) : Promise < Repository | null > ;
292+ openRepository ( root : Uri ) : Promise < Repository | null >
251293
252294 registerRemoteSourcePublisher ( publisher : RemoteSourcePublisher ) : Disposable ;
253295 registerRemoteSourceProvider ( provider : RemoteSourceProvider ) : Disposable ;
254296 registerCredentialsProvider ( provider : CredentialsProvider ) : Disposable ;
297+ registerPostCommitCommandsProvider ( provider : PostCommitCommandsProvider ) : Disposable ;
255298 registerPushErrorHandler ( handler : PushErrorHandler ) : Disposable ;
256299}
257300
@@ -263,7 +306,7 @@ export interface GitExtension {
263306 /**
264307 * Returns a specific API version.
265308 *
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
267310 * [GitExtension.onDidChangeEnablement](#GitExtension.onDidChangeEnablement) event
268311 * to know when the extension becomes enabled/disabled.
269312 *
@@ -309,4 +352,5 @@ export const enum GitErrorCodes {
309352 PatchDoesNotApply = 'PatchDoesNotApply' ,
310353 NoPathFound = 'NoPathFound' ,
311354 UnknownPath = 'UnknownPath' ,
355+ EmptyCommitMessage = 'EmptyCommitMessage'
312356}
0 commit comments