提交 5f31035e 编写于 作者: J Joao Moreno

Merge branch 'git_pull_from' of https://github.com/Krzysztof-Cieslak/vscode...

Merge branch 'git_pull_from' of https://github.com/Krzysztof-Cieslak/vscode into Krzysztof-Cieslak-git_pull_from
......@@ -192,6 +192,11 @@
"title": "%command.pullRebase%",
"category": "Git"
},
{
"command": "git.pullFrom",
"title": "%command.pullFrom%",
"category": "Git"
},
{
"command": "git.push",
"title": "%command.push%",
......@@ -325,6 +330,10 @@
"command": "git.pullRebase",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.pullFrom",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.push",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
......@@ -377,6 +386,11 @@
"group": "1_sync",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.pullFrom",
"group": "1_sync",
"when": "config.git.enabled && scmProvider == git && gitState == idle"
},
{
"command": "git.push",
"group": "1_sync",
......
......@@ -25,6 +25,7 @@
"command.merge": "Merge Branch...",
"command.pull": "Pull",
"command.pullRebase": "Pull (Rebase)",
"command.pullFrom": "Pull (From Remote)",
"command.push": "Push",
"command.pushTo": "Push to...",
"command.sync": "Sync",
......
......@@ -834,6 +834,32 @@ export class CommandCenter {
await this.model.pullWithRebase();
}
@command('git.pullFrom')
async pullFrom(): Promise<void> {
const remotes = this.model.remotes;
if (remotes.length === 0) {
window.showWarningMessage(localize('no remotes to pull', "Your repository has no remotes configured to pull from."));
return;
}
if (!this.model.HEAD || !this.model.HEAD.name) {
window.showWarningMessage(localize('nobranchToPull', "Please select branch."));
return;
}
const branchName = this.model.HEAD.name;
const picks = remotes.map(r => ({ label: r.name, description: r.url }));
const placeHolder = localize('pick remote pull', "Pick a remote to pull the branch '{0}' from:", branchName);
const pick = await window.showQuickPick(picks, { placeHolder });
if (!pick) {
return;
}
await this.model.pullFromRemote(pick.label, branchName);
}
@command('git.push')
async push(): Promise<void> {
const remotes = this.model.remotes;
......
......@@ -748,12 +748,15 @@ export class Repository {
}
}
async pull(rebase?: boolean): Promise<void> {
async pull(rebase?: boolean, remote?: string, branch?: string): Promise<void> {
const args = ['pull'];
if (rebase) {
args.push('-r');
}
if (remote && branch) {
args.push(remote, branch);
}
try {
await this.run(args);
......
......@@ -496,6 +496,11 @@ export class Model implements Disposable {
await this.run(Operation.Pull, () => this.repository.pull(true));
}
@throttle
async pullFromRemote(remote : string, branch : string): Promise<void> {
await this.run(Operation.Pull, () => this.repository.pull(false, remote, branch));
}
@throttle
async push(): Promise<void> {
await this.run(Operation.Push, () => this.repository.push());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册