Skip to content

Commit 980fb4b

Browse files
committed
Merge commit 'refs/pull/76342/head' of github.com:microsoft/vscode into pr/76342
2 parents b8d2bad + d235f18 commit 980fb4b

5 files changed

Lines changed: 49 additions & 0 deletions

File tree

extensions/git/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@
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": {
@@ -660,6 +665,10 @@
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": [
@@ -813,6 +822,11 @@
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",

extensions/git/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
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.",

extensions/git/src/commands.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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

extensions/git/src/git.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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 (/No stash found/.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();

extensions/git/src/repository.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)