File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 401401 "command" : " git.stashApplyLatest" ,
402402 "title" : " %command.stashApplyLatest%" ,
403403 "category" : " Git"
404+ },
405+ {
406+ "command" : " git.stashDrop" ,
407+ "title" : " %command.stashDrop%" ,
408+ "category" : " Git"
404409 }
405410 ],
406411 "menus" : {
660665 {
661666 "command" : " git.stashApplyLatest" ,
662667 "when" : " config.git.enabled && gitOpenRepositoryCount != 0"
668+ },
669+ {
670+ "command" : " git.stashDrop" ,
671+ "when" : " config.get.enabled && gitOpenRepositoryCount != 0"
663672 }
664673 ],
665674 "scm/title" : [
813822 "group" : " 6_stash" ,
814823 "when" : " scmProvider == git"
815824 },
825+ {
826+ "command" : " git.stashDrop" ,
827+ "group" : " 6_stash" ,
828+ "when" : " scmProvider == git"
829+ },
816830 {
817831 "command" : " git.showOutput" ,
818832 "group" : " 7_repository" ,
Original file line number Diff line number Diff line change 6464 "command.stashPopLatest" : " Pop Latest Stash" ,
6565 "command.stashApply" : " Apply Stash..." ,
6666 "command.stashApplyLatest" : " Apply Latest Stash" ,
67+ "command.stashDrop" : " Drop Stash..." ,
6768 "config.enabled" : " Whether git is enabled." ,
6869 "config.path" : " Path and filename of the git executable, e.g. `C:\\ Program Files\\ Git\\ bin\\ git.exe` (Windows)." ,
6970 "config.autoRepositoryDetection" : " Configures when repositories should be automatically detected." ,
Original file line number Diff line number Diff line change @@ -2241,6 +2241,18 @@ export class CommandCenter {
22412241 await repository . applyStash ( ) ;
22422242 }
22432243
2244+ @command ( 'git.stashDrop' , { repository : true } )
2245+ async stashDrop ( repository : Repository ) : Promise < void > {
2246+ const placeHolder = localize ( 'pick stash to drop' , "Pick a stash to drop" ) ;
2247+ const stash = await this . pickStash ( repository , placeHolder ) ;
2248+
2249+ if ( ! stash ) {
2250+ return ;
2251+ }
2252+
2253+ await repository . dropStash ( stash . index ) ;
2254+ }
2255+
22442256 private async pickStash ( repository : Repository , placeHolder : string ) : Promise < Stash | undefined > {
22452257 const stashes = await repository . getStashes ( ) ;
22462258
Original file line number Diff line number Diff line change @@ -1597,6 +1597,24 @@ export class Repository {
15971597 }
15981598 }
15991599
1600+ async dropStash ( index : number ) : Promise < void > {
1601+ const args = [ 'stash' , 'drop' ] ;
1602+
1603+ if ( typeof index === 'number' ) {
1604+ args . push ( `stash@{${ index } }` ) ;
1605+
1606+ try {
1607+ await this . run ( args ) ;
1608+ }
1609+ } catch ( err ) {
1610+ if ( / N o s t a s h f o u n d / . test ( err . stderr || '' ) ) {
1611+ err . gitErrorCode = GitErrorCodes . NoStashFound ;
1612+ }
1613+
1614+ throw err ;
1615+ }
1616+ }
1617+
16001618 getStatus ( limit = 5000 ) : Promise < { status : IFileStatus [ ] ; didHitLimit : boolean ; } > {
16011619 return new Promise < { status : IFileStatus [ ] ; didHitLimit : boolean ; } > ( ( c , e ) => {
16021620 const parser = new GitStatusParser ( ) ;
Original file line number Diff line number Diff line change @@ -1254,6 +1254,10 @@ export class Repository implements Disposable {
12541254 return await this . run ( Operation . Stash , ( ) => this . repository . popStash ( index ) ) ;
12551255 }
12561256
1257+ async dropStash ( index ?: number ) : Promise < void > {
1258+ return await this . run ( Operation . Stash , ( ) => this . repository . dropStash ( index ) ) ;
1259+ }
1260+
12571261 async applyStash ( index ?: number ) : Promise < void > {
12581262 return await this . run ( Operation . Stash , ( ) => this . repository . applyStash ( index ) ) ;
12591263 }
You can’t perform that action at this time.
0 commit comments