提交 13484ae9 编写于 作者: K Krzysztof Cieślak

Add commands

上级 4cd45c49
......@@ -251,6 +251,21 @@
"command": "git.ignore",
"title": "%command.ignore%",
"category": "Git"
},
{
"command": "git.stash",
"title": "%command.stash%",
"category": "Git"
},
{
"command": "git.stashPop",
"title": "%command.stashPop%",
"category": "Git"
},
{
"command": "git.stashPopLatest",
"title": "%command.stashPopLatest%",
"category": "Git"
}
],
"menus": {
......@@ -402,6 +417,18 @@
{
"command": "git.showOutput",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.stash",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.stashPop",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.stashPopLatest",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
}
],
"scm/title": [
......@@ -501,7 +528,22 @@
},
{
"command": "git.showOutput",
"group": "5_output",
"group": "6_output",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.stash",
"group": "5_stash",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.stashPop",
"group": "5_stash",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.stashPopLatest",
"group": "5_stash",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
}
],
......
......@@ -37,6 +37,9 @@
"command.publish": "Publish Branch",
"command.showOutput": "Show Git Output",
"command.ignore": "Add File to .gitignore",
"command.stash": "Stash",
"command.stashPop": "Stash Pop",
"command.stashPopLatest": "Stash Pop Latest",
"config.enabled": "Whether git is enabled",
"config.path": "Path to the git executable",
"config.autorefresh": "Whether auto refreshing is enabled",
......
......@@ -1092,6 +1092,45 @@ export class CommandCenter {
await this.model.ignore(uris);
}
@command('git.stash')
async stash() : Promise<void> {
const noUnstagedChanges = this.model.workingTreeGroup.resources.length === 0;
if (noUnstagedChanges){
window.showInformationMessage(localize('no changes stash', "There are no changes to stash."));
return;
}
return await this.model.stash();
}
@command('git.stashPop')
async stashPop(): Promise<void> {
const noStashes = this.model.stashes.length === 0;
if (noStashes){
window.showInformationMessage(localize('no stashes', "There are no stashes to restore."));
return;
}
const picks = this.model.stashes.map(r => `#${r.id}: ${r.description}`);
const placeHolder = localize('pick stash', "Pick a stash");
const choice = await window.showQuickPick(picks, { placeHolder });
if (!choice) {
return;
}
return await this.model.stash(true, choice);
}
@command('git.stashPopLatest')
async stashPopLatest(): Promise<void> {
const noStashes = this.model.stashes.length === 0;
if (noStashes){
window.showInformationMessage(localize('no stashes', "There are no stashes to restore."));
return;
}
return await this.model.stash(true);
}
private createCommand(id: string, key: string, method: Function, skipModelCheck: boolean): (...args: any[]) => any {
const result = (...args) => {
if (!skipModelCheck && !this.model) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册