mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 18:48:45 -05:00
Avoids remote disambiguation quick pick
This commit is contained in:
@@ -10,6 +10,7 @@ import { OpenInRemoteCommandArgs } from './openInRemote';
|
|||||||
|
|
||||||
export interface OpenBranchInRemoteCommandArgs {
|
export interface OpenBranchInRemoteCommandArgs {
|
||||||
branch?: string;
|
branch?: string;
|
||||||
|
remote?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
|
export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
|
||||||
@@ -21,7 +22,9 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
|
|||||||
protected async preExecute(context: CommandContext, args: OpenBranchInRemoteCommandArgs = {}): Promise<any> {
|
protected async preExecute(context: CommandContext, args: OpenBranchInRemoteCommandArgs = {}): Promise<any> {
|
||||||
if (isCommandViewContextWithBranch(context)) {
|
if (isCommandViewContextWithBranch(context)) {
|
||||||
args = { ...args };
|
args = { ...args };
|
||||||
|
|
||||||
args.branch = context.node.branch.name;
|
args.branch = context.node.branch.name;
|
||||||
|
args.remote = context.node.branch.getRemote();
|
||||||
return this.execute(context.editor, context.uri, args);
|
return this.execute(context.editor, context.uri, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +60,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
|
|||||||
type: 'branch',
|
type: 'branch',
|
||||||
branch: args.branch
|
branch: args.branch
|
||||||
},
|
},
|
||||||
|
remote: args.remote,
|
||||||
remotes
|
remotes
|
||||||
} as OpenInRemoteCommandArgs);
|
} as OpenInRemoteCommandArgs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,15 +35,13 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
|
|||||||
if (!repoPath) return undefined;
|
if (!repoPath) return undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), r => r.url, r => !!r.provider);
|
const remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), r => r.url, r => !!r.provider);
|
||||||
if (args.remote !== undefined) {
|
|
||||||
remotes = remotes.filter(r => r.name === args.remote);
|
|
||||||
}
|
|
||||||
|
|
||||||
return commands.executeCommand(Commands.OpenInRemote, uri, {
|
return commands.executeCommand(Commands.OpenInRemote, uri, {
|
||||||
resource: {
|
resource: {
|
||||||
type: 'branches'
|
type: 'branches'
|
||||||
},
|
},
|
||||||
|
remote: args.remote,
|
||||||
remotes
|
remotes
|
||||||
} as OpenInRemoteCommandArgs);
|
} as OpenInRemoteCommandArgs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { Logger } from '../logger';
|
|||||||
import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickPicks';
|
||||||
|
|
||||||
export interface OpenInRemoteCommandArgs {
|
export interface OpenInRemoteCommandArgs {
|
||||||
|
remote?: string;
|
||||||
remotes?: GitRemote[];
|
remotes?: GitRemote[];
|
||||||
resource?: RemoteResource;
|
resource?: RemoteResource;
|
||||||
|
|
||||||
@@ -26,6 +27,14 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
|
|||||||
args = { ...args };
|
args = { ...args };
|
||||||
if (args.remotes === undefined || args.resource === undefined) return undefined;
|
if (args.remotes === undefined || args.resource === undefined) return undefined;
|
||||||
|
|
||||||
|
if (args.remote !== undefined) {
|
||||||
|
const remotes = args.remotes.filter(r => r.name === args.remote);
|
||||||
|
// Only filter if we get some results
|
||||||
|
if (remotes.length > 0) {
|
||||||
|
args.remotes = remotes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (args.remotes.length === 1) {
|
if (args.remotes.length === 1) {
|
||||||
this.ensureRemoteBranchName(args);
|
this.ensureRemoteBranchName(args);
|
||||||
|
|||||||
@@ -35,15 +35,13 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
|
|||||||
if (!repoPath) return undefined;
|
if (!repoPath) return undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), r => r.url, r => !!r.provider);
|
const remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), r => r.url, r => !!r.provider);
|
||||||
if (args.remote !== undefined) {
|
|
||||||
remotes = remotes.filter(r => r.name === args.remote);
|
|
||||||
}
|
|
||||||
|
|
||||||
return commands.executeCommand(Commands.OpenInRemote, uri, {
|
return commands.executeCommand(Commands.OpenInRemote, uri, {
|
||||||
resource: {
|
resource: {
|
||||||
type: 'repo'
|
type: 'repo'
|
||||||
},
|
},
|
||||||
|
remote: args.remote,
|
||||||
remotes
|
remotes
|
||||||
} as OpenInRemoteCommandArgs);
|
} as OpenInRemoteCommandArgs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user