提交 27b824b3 编写于 作者: E Eric Amodio

Adds ability to pass remote/refspec to pushTo cmds

上级 d076ee1b
...@@ -277,6 +277,12 @@ interface PushOptions { ...@@ -277,6 +277,12 @@ interface PushOptions {
pushType: PushType; pushType: PushType;
forcePush?: boolean; forcePush?: boolean;
silent?: boolean; silent?: boolean;
pushTo?: {
remote?: string;
refspec?: string;
setUpstream?: boolean;
}
} }
class CommandErrorOutputTextDocumentContentProvider implements TextDocumentContentProvider { class CommandErrorOutputTextDocumentContentProvider implements TextDocumentContentProvider {
...@@ -2112,23 +2118,27 @@ export class CommandCenter { ...@@ -2112,23 +2118,27 @@ export class CommandCenter {
} }
} else { } else {
const branchName = repository.HEAD.name; const branchName = repository.HEAD.name;
const addRemote = new AddRemoteItem(this); if (!pushOptions.pushTo?.remote) {
const picks = [...remotes.filter(r => r.pushUrl !== undefined).map(r => ({ label: r.name, description: r.pushUrl })), addRemote]; const addRemote = new AddRemoteItem(this);
const placeHolder = localize('pick remote', "Pick a remote to publish the branch '{0}' to:", branchName); const picks = [...remotes.filter(r => r.pushUrl !== undefined).map(r => ({ label: r.name, description: r.pushUrl })), addRemote];
const choice = await window.showQuickPick(picks, { placeHolder }); const placeHolder = localize('pick remote', "Pick a remote to publish the branch '{0}' to:", branchName);
const choice = await window.showQuickPick(picks, { placeHolder });
if (!choice) { if (!choice) {
return; return;
} }
if (choice === addRemote) { if (choice === addRemote) {
const newRemote = await this.addRemote(repository); const newRemote = await this.addRemote(repository);
if (newRemote) { if (newRemote) {
await repository.pushTo(newRemote, branchName, undefined, forcePushMode); await repository.pushTo(newRemote, branchName, undefined, forcePushMode);
}
} else {
await repository.pushTo(choice.label, branchName, undefined, forcePushMode);
} }
} else { } else {
await repository.pushTo(choice.label, branchName, undefined, forcePushMode); await repository.pushTo(pushOptions.pushTo.remote, pushOptions.pushTo.refspec || branchName, pushOptions.pushTo.setUpstream, forcePushMode);
} }
} }
} }
...@@ -2169,13 +2179,13 @@ export class CommandCenter { ...@@ -2169,13 +2179,13 @@ export class CommandCenter {
} }
@command('git.pushTo', { repository: true }) @command('git.pushTo', { repository: true })
async pushTo(repository: Repository): Promise<void> { async pushTo(repository: Repository, remote?: string, refspec?: string, setUpstream?: boolean): Promise<void> {
await this._push(repository, { pushType: PushType.PushTo }); await this._push(repository, { pushType: PushType.PushTo, pushTo: { remote: remote, refspec: refspec, setUpstream: setUpstream } });
} }
@command('git.pushToForce', { repository: true }) @command('git.pushToForce', { repository: true })
async pushToForce(repository: Repository): Promise<void> { async pushToForce(repository: Repository, remote?: string, refspec?: string, setUpstream?: boolean): Promise<void> {
await this._push(repository, { pushType: PushType.PushTo, forcePush: true }); await this._push(repository, { pushType: PushType.PushTo, pushTo: { remote: remote, refspec: refspec, setUpstream: setUpstream }, forcePush: true });
} }
@command('git.pushTags', { repository: true }) @command('git.pushTags', { repository: true })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册