@@ -266,14 +266,14 @@ export class GitExtension implements IGitExtension {
266
266
* A signal emitted when the Git stash changes.
267
267
*
268
268
*/
269
- get stashChanged ( ) : ISignal < IGitExtension , IChangedArgs < Git . IStash > > {
269
+ get stashChanged ( ) : ISignal < IGitExtension , IChangedArgs < Git . IStash [ ] > > {
270
270
return this . _stashChanged ;
271
271
}
272
272
273
273
/**
274
274
* The repository stash
275
275
*/
276
- get stash ( ) : Git . IStash {
276
+ get stash ( ) : Git . IStash [ ] {
277
277
return this . _stash ;
278
278
}
279
279
@@ -1655,64 +1655,36 @@ export class GitExtension implements IGitExtension {
1655
1655
1656
1656
// Get the entire stash list
1657
1657
try {
1658
- const stashListData =
1659
- await this . _taskHandler . execute < Git . IStashListResult > (
1660
- 'git:refresh:stash' ,
1661
- async ( ) => {
1662
- return await requestAPI < Git . IStashListResult > (
1663
- URLExt . join ( path , 'stash' ) ,
1664
- 'GET'
1665
- ) ;
1666
- }
1667
- ) ;
1668
-
1669
- // Contains the raw message
1670
- const stashMsgList = stashListData . message . split ( '\n' ) . slice ( 0 , - 1 ) ;
1671
-
1672
- const stashList : Git . IStashEntry [ ] = [ ] ;
1673
- for ( const index in stashMsgList ) {
1674
- const stashInfo = stashMsgList [ index ] . split ( ':' ) ;
1675
-
1676
- const WIPMatch = stashInfo [ 1 ] . match ( / W I P o n ( .* ) / ) ;
1677
- const branchName = WIPMatch ? WIPMatch [ 1 ] : stashInfo [ 1 ] . split ( ' ' ) [ 2 ] ;
1678
-
1679
- const stashMsg = stashInfo [ 2 ] . replace ( / ^ \s + / , '' ) ;
1680
-
1681
- stashList . push ( {
1682
- index : parseInt ( index , 10 ) ,
1683
- branch : branchName ,
1684
- message : stashMsg ,
1685
- files : [ ]
1686
- } ) ;
1687
- }
1688
- const fileData = await this . _taskHandler . execute < Git . IStashListResult > (
1658
+ const response = await this . _taskHandler . execute < Git . IStashListResult > (
1689
1659
'git:refresh:stash' ,
1690
1660
async ( ) => {
1691
- const results = await Promise . all (
1692
- stashList . map ( ( { index } ) =>
1693
- requestAPI < Git . IStashListResult > (
1694
- URLExt . join ( path , 'stash' ) + `?index=${ index } ` ,
1695
- 'GET'
1696
- )
1697
- )
1661
+ return await requestAPI < Git . IStashListResult > (
1662
+ URLExt . join ( path , 'stash' ) ,
1663
+ 'GET'
1698
1664
) ;
1699
- return {
1700
- message : 'Stash list result' ,
1701
- command : 'git:refresh:stash' ,
1702
- code : 0 ,
1703
- results
1704
- } ;
1705
1665
}
1706
1666
) ;
1707
1667
1708
- stashList . forEach ( ( stash , index ) => {
1709
- stash . files . push (
1710
- ...( fileData . results ?? [ ] ) [ index ] . message . split ( '\n' ) . slice ( 0 , - 1 )
1711
- ) ;
1712
- } ) ;
1668
+ const allStashFiles = await this . _taskHandler . execute <
1669
+ Git . IStashShowResult [ ]
1670
+ > ( 'git:refresh:stash' , ( ) =>
1671
+ Promise . all (
1672
+ response . stashes . map ( ( { index } ) =>
1673
+ requestAPI < Git . IStashShowResult > (
1674
+ URLExt . join ( path , 'stash' ) + `?index=${ index } ` ,
1675
+ 'GET'
1676
+ )
1677
+ )
1678
+ )
1679
+ ) ;
1680
+ const stashList : Git . IStash [ ] = response . stashes . map ( ( s , index ) =>
1681
+ Object . assign ( s , {
1682
+ files : allStashFiles [ index ] . files
1683
+ } )
1684
+ ) ;
1713
1685
1714
1686
if ( ! this . isStashDeepEqual ( stashList , this . _stash ) ) {
1715
- const change : IChangedArgs < Git . IStash > = {
1687
+ const change : IChangedArgs < Git . IStash [ ] > = {
1716
1688
name : 'stash' ,
1717
1689
newValue : stashList ,
1718
1690
oldValue : this . _stash
@@ -1772,10 +1744,7 @@ export class GitExtension implements IGitExtension {
1772
1744
* @throws {Git.GitResponseError } If the server response is not ok
1773
1745
* @throws {ServerConnection.NetworkError } If the request cannot be made
1774
1746
*/
1775
- protected isStashDeepEqual (
1776
- a : Git . IStashEntry [ ] ,
1777
- b : Git . IStashEntry [ ]
1778
- ) : boolean {
1747
+ protected isStashDeepEqual ( a : Git . IStash [ ] , b : Git . IStash [ ] ) : boolean {
1779
1748
if ( a ?. length !== b ?. length ) {
1780
1749
return false ;
1781
1750
}
@@ -2212,7 +2181,7 @@ export class GitExtension implements IGitExtension {
2212
2181
state : Git . State . DEFAULT ,
2213
2182
files : [ ]
2214
2183
} ;
2215
- private _stash : Git . IStash = [ ] ;
2184
+ private _stash : Git . IStash [ ] = [ ] ;
2216
2185
private _pathRepository : string | null = null ;
2217
2186
private _branches : Git . IBranch [ ] = [ ] ;
2218
2187
private _tagsList : Git . ITag [ ] = [ ] ;
@@ -2251,7 +2220,7 @@ export class GitExtension implements IGitExtension {
2251
2220
IGitExtension ,
2252
2221
IChangedArgs < string | null >
2253
2222
> ( this ) ;
2254
- private _stashChanged = new Signal < IGitExtension , IChangedArgs < Git . IStash > > (
2223
+ private _stashChanged = new Signal < IGitExtension , IChangedArgs < Git . IStash [ ] > > (
2255
2224
this
2256
2225
) ;
2257
2226
private _statusChanged = new Signal < IGitExtension , Git . IStatus > ( this ) ;
0 commit comments