mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
parent
4ba9130583
commit
42ab4c41a4
|
@ -182,6 +182,11 @@
|
|||
"title": "%command.pullRebase%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.pullFrom",
|
||||
"title": "%command.pullFrom%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.push",
|
||||
"title": "%command.push%",
|
||||
|
@ -306,6 +311,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"
|
||||
|
@ -358,6 +367,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",
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"command.branch": "Create Branch...",
|
||||
"command.pull": "Pull",
|
||||
"command.pullRebase": "Pull (Rebase)",
|
||||
"command.pullFrom": "Pull from...",
|
||||
"command.push": "Push",
|
||||
"command.pushTo": "Push to...",
|
||||
"command.sync": "Sync",
|
||||
|
|
|
@ -723,6 +723,31 @@ export class CommandCenter {
|
|||
await this.model.pull(true);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
const picks = remotes.map(r => ({ label: r.name, description: r.url }));
|
||||
const placeHolder = localize('pick remote pull', "Pick a remote to pull from");
|
||||
const pickRemote = await window.showQuickPick(picks, { placeHolder });
|
||||
|
||||
const pickBranch = await window.showInputBox({
|
||||
prompt: localize('pick pull branch', "Type a branch to pull"),
|
||||
ignoreFocusOut: true
|
||||
});
|
||||
|
||||
if (!pickRemote || !pickBranch) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.model.pull(false, pickRemote.label, pickBranch);
|
||||
}
|
||||
|
||||
@command('git.push')
|
||||
async push(): Promise<void> {
|
||||
const remotes = this.model.remotes;
|
||||
|
@ -894,4 +919,4 @@ export class CommandCenter {
|
|||
dispose(): void {
|
||||
this.disposables.forEach(d => d.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,6 +291,8 @@ function getGitErrorCode(stderr: string): string | undefined {
|
|||
return GitErrorCodes.RepositoryNotFound;
|
||||
} else if (/unable to access/.test(stderr)) {
|
||||
return GitErrorCodes.CantAccessRemote;
|
||||
} else if (/Couldn\'t find remote ref/.test(stderr)) {
|
||||
return GitErrorCodes.CantAccessRemote;
|
||||
}
|
||||
|
||||
return void 0;
|
||||
|
@ -730,13 +732,18 @@ 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);
|
||||
args.push(branch);
|
||||
}
|
||||
|
||||
try {
|
||||
await this.run(args);
|
||||
} catch (err) {
|
||||
|
|
|
@ -474,8 +474,8 @@ export class Model implements Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
async pull(rebase?: boolean): Promise<void> {
|
||||
await this.run(Operation.Pull, () => this.repository.pull(rebase));
|
||||
async pull(rebase?: boolean, remote?: string, branch?: string): Promise<void> {
|
||||
await this.run(Operation.Pull, () => this.repository.pull(rebase, remote, branch));
|
||||
}
|
||||
|
||||
async push(remote?: string, name?: string, options?: PushOptions): Promise<void> {
|
||||
|
|
Loading…
Reference in a new issue