@@ -8,6 +8,7 @@ import type { GitStashCommit } from '../../../../git/models/commit';
8
8
import { GitCommit , GitCommitIdentity } from '../../../../git/models/commit' ;
9
9
import type { GitFileStatus } from '../../../../git/models/file' ;
10
10
import { GitFileChange , GitFileWorkingTreeStatus , mapFilesWithStats } from '../../../../git/models/file' ;
11
+ import { RepositoryChange } from '../../../../git/models/repository' ;
11
12
import type { GitStash } from '../../../../git/models/stash' ;
12
13
import type { ParserWithFilesAndMaybeStats } from '../../../../git/parsers/logParser' ;
13
14
import { createLogParserWithFiles , createLogParserWithFilesAndStats } from '../../../../git/parsers/logParser' ;
@@ -33,10 +34,12 @@ export class StashGitSubProvider implements GitStashSubProvider {
33
34
private readonly cache : GitCache ,
34
35
) { }
35
36
37
+ @gate ( )
36
38
@log ( )
37
39
async applyStash ( repoPath : string , stashName : string , options ?: { deleteAfter ?: boolean } ) : Promise < void > {
38
40
try {
39
41
await this . git . stash__apply ( repoPath , stashName , Boolean ( options ?. deleteAfter ) ) ;
42
+ this . container . events . fire ( 'git:repo:change' , { repoPath : repoPath , changes : [ RepositoryChange . Stash ] } ) ;
40
43
} catch ( ex ) {
41
44
if ( ex instanceof Error ) {
42
45
const msg : string = ex . message ?? '' ;
@@ -188,6 +191,7 @@ export class StashGitSubProvider implements GitStashSubProvider {
188
191
return gitStash ?? undefined ;
189
192
}
190
193
194
+ @gate ( )
191
195
@log ( )
192
196
async getStashCommitFiles (
193
197
repoPath : string ,
@@ -270,12 +274,15 @@ export class StashGitSubProvider implements GitStashSubProvider {
270
274
return undefined ;
271
275
}
272
276
277
+ @gate ( )
273
278
@log ( )
274
279
async deleteStash ( repoPath : string , stashName : string , ref ?: string ) : Promise < void > {
275
280
await this . git . stash__delete ( repoPath , stashName , ref ) ;
281
+ this . container . events . fire ( 'git:repo:change' , { repoPath : repoPath , changes : [ RepositoryChange . Stash ] } ) ;
276
282
this . container . events . fire ( 'git:cache:reset' , { repoPath : repoPath , caches : [ 'stashes' ] } ) ;
277
283
}
278
284
285
+ @gate ( )
279
286
@log ( )
280
287
async renameStash (
281
288
repoPath : string ,
@@ -285,6 +292,7 @@ export class StashGitSubProvider implements GitStashSubProvider {
285
292
stashOnRef ?: string ,
286
293
) : Promise < void > {
287
294
await this . git . stash__rename ( repoPath , stashName , ref , message , stashOnRef ) ;
295
+ this . container . events . fire ( 'git:repo:change' , { repoPath : repoPath , changes : [ RepositoryChange . Stash ] } ) ;
288
296
this . container . events . fire ( 'git:cache:reset' , { repoPath : repoPath , caches : [ 'stashes' ] } ) ;
289
297
}
290
298
@@ -295,52 +303,53 @@ export class StashGitSubProvider implements GitStashSubProvider {
295
303
uris ?: Uri [ ] ,
296
304
options ?: { includeUntracked ?: boolean ; keepIndex ?: boolean ; onlyStaged ?: boolean } ,
297
305
) : Promise < void > {
298
- try {
299
- if ( ! uris ?. length ) {
300
- await this . git . stash__push ( repoPath , message , options ) ;
301
- return ;
302
- }
306
+ if ( ! uris ?. length ) {
307
+ await this . git . stash__push ( repoPath , message , options ) ;
308
+ this . container . events . fire ( 'git:repo:change' , { repoPath : repoPath , changes : [ RepositoryChange . Stash ] } ) ;
309
+ this . container . events . fire ( 'git:cache:reset' , { repoPath : repoPath , caches : [ 'stashes' , 'status' ] } ) ;
310
+ return ;
311
+ }
303
312
304
- await this . git . ensureGitVersion (
305
- '2.13.2' ,
306
- 'Stashing individual files' ,
307
- ' Please retry by stashing everything or install a more recent version of Git and try again.' ,
308
- ) ;
313
+ await this . git . ensureGitVersion (
314
+ '2.13.2' ,
315
+ 'Stashing individual files' ,
316
+ ' Please retry by stashing everything or install a more recent version of Git and try again.' ,
317
+ ) ;
309
318
310
- const pathspecs = uris . map ( u => `./${ splitPath ( u , repoPath ) [ 0 ] } ` ) ;
319
+ const pathspecs = uris . map ( u => `./${ splitPath ( u , repoPath ) [ 0 ] } ` ) ;
311
320
312
- const stdinVersion = '2.30.0' ;
313
- let stdin = await this . git . isAtLeastVersion ( stdinVersion ) ;
314
- if ( stdin && options ?. onlyStaged && uris . length ) {
315
- // Since Git doesn't support --staged with --pathspec-from-file try to pass them in directly
316
- stdin = false ;
317
- }
318
-
319
- // If we don't support stdin, then error out if we are over the maximum allowed git cli length
320
- if ( ! stdin && countStringLength ( pathspecs ) > maxGitCliLength ) {
321
- await this . git . ensureGitVersion (
322
- stdinVersion ,
323
- `Stashing so many files (${ pathspecs . length } ) at once` ,
324
- ' Please retry by stashing fewer files or install a more recent version of Git and try again.' ,
325
- ) ;
326
- }
321
+ const stdinVersion = '2.30.0' ;
322
+ let stdin = await this . git . isAtLeastVersion ( stdinVersion ) ;
323
+ if ( stdin && options ?. onlyStaged && uris . length ) {
324
+ // Since Git doesn't support --staged with --pathspec-from-file try to pass them in directly
325
+ stdin = false ;
326
+ }
327
327
328
- await this . git . stash__push ( repoPath , message , {
329
- ... options ,
330
- pathspecs : pathspecs ,
331
- stdin : stdin ,
332
- } ) ;
333
- } finally {
334
- this . container . events . fire ( 'git:cache:reset' , { repoPath : repoPath , caches : [ 'stashes' , 'status' ] } ) ;
328
+ // If we don't support stdin, then error out if we are over the maximum allowed git cli length
329
+ if ( ! stdin && countStringLength ( pathspecs ) > maxGitCliLength ) {
330
+ await this . git . ensureGitVersion (
331
+ stdinVersion ,
332
+ `Stashing so many files ( ${ pathspecs . length } ) at once` ,
333
+ ' Please retry by stashing fewer files or install a more recent version of Git and try again.' ,
334
+ ) ;
335
335
}
336
+
337
+ await this . git . stash__push ( repoPath , message , {
338
+ ...options ,
339
+ pathspecs : pathspecs ,
340
+ stdin : stdin ,
341
+ } ) ;
342
+ this . container . events . fire ( 'git:cache:reset' , { repoPath : repoPath , caches : [ 'stashes' , 'status' ] } ) ;
336
343
}
337
344
345
+ @gate ( )
338
346
@log ( )
339
347
async saveSnapshot ( repoPath : string , message ?: string ) : Promise < void > {
340
348
const id = await this . git . stash__create ( repoPath ) ;
341
349
if ( id == null ) return ;
342
350
343
351
await this . git . stash__store ( repoPath , id , message ) ;
352
+ this . container . events . fire ( 'git:repo:change' , { repoPath : repoPath , changes : [ RepositoryChange . Stash ] } ) ;
344
353
this . container . events . fire ( 'git:cache:reset' , { repoPath : repoPath , caches : [ 'stashes' ] } ) ;
345
354
}
346
355
}
0 commit comments