提交 b2350b41 编写于 作者: O Omkar Manjrekar

Added commands

上级 1580cd18
......@@ -315,6 +315,16 @@
"title": "%command.pushWithTagsForce%",
"category": "Git"
},
{
"command": "git.addRemote",
"title": "%command.addRemote%",
"category": "Git"
},
{
"command": "git.removeRemote",
"title": "%command.removeRemote%",
"category": "Git"
}
{
"command": "git.sync",
"title": "%command.sync%",
......@@ -561,6 +571,14 @@
"command": "git.pushWithTagsForce",
"when": "config.git.enabled && config.git.allowForcePush && gitOpenRepositoryCount != 0"
},
{
"command": "git.addRemote",
"when": "config.git.enabled && gitOpenRepositoryCount != 0"
},
{
"command": "git.removeRemote",
"when": "config.git.enabled && gitOpenRepositoryCount != 0"
},
{
"command": "git.sync",
"when": "config.git.enabled && gitOpenRepositoryCount != 0"
......
......@@ -47,6 +47,8 @@
"command.pushToForce": "Push to... (Force)",
"command.pushWithTags": "Push With Tags",
"command.pushWithTagsForce": "Push With Tags (Force)",
"command.addRemote": "Add Remote",
"command.removeRemote": "Remove Remote",
"command.sync": "Sync",
"command.syncRebase": "Sync (Rebase)",
"command.publish": "Publish Branch",
......
......@@ -1711,6 +1711,50 @@ export class CommandCenter {
await this._push(repository, { pushType: PushType.PushTo, forcePush: true });
}
private async _remote(repository: Repository, rebase: boolean): Promise<void> {
const HEAD = repository.HEAD;
if (!HEAD || !HEAD.upstream) {
return;
}
const remoteName = HEAD.remote || HEAD.upstream.remote;
const remote = repository.remotes.find(r => r.name === remoteName);
const isReadonly = remote && remote.isReadOnly;
const config = workspace.getConfiguration('git');
const shouldPrompt = !isReadonly && config.get<boolean>('confirmSync') === true;
if (shouldPrompt) {
const message = localize('sync is unpredictable', "This action will push and pull commits to and from '{0}/{1}'.", HEAD.upstream.remote, HEAD.upstream.name);
const yes = localize('ok', "OK");
const neverAgain = localize('never again', "OK, Don't Show Again");
const pick = await window.showWarningMessage(message, { modal: true }, yes, neverAgain);
if (pick === neverAgain) {
await config.update('confirmSync', false, true);
} else if (pick !== yes) {
return;
}
}
if (rebase) {
await repository.syncRebase(HEAD);
} else {
await repository.sync(HEAD);
}
}
// @command('git.addRemote', { repository: true })
// async addRemote(repository: Repository): Promise<void> {
// await this._remote(repository, { pushType: PushType.PushTo });
// }
// @command('git.removeRemote', { repository: true })
// async removeRemote(repository: Repository): Promise<void> {
// await this._remote(repository, { pushType: PushType.PushTo, forcePush: true });
// }
private async _sync(repository: Repository, rebase: boolean): Promise<void> {
const HEAD = repository.HEAD;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册