Skip to content

Commit

Permalink
Reworks branches/tags quickpick
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Nov 3, 2018
1 parent 755c1ff commit 87e214c
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 175 deletions.
2 changes: 1 addition & 1 deletion src/commands/diffWithRevision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {

return commands.executeCommand(Commands.DiffWithRevision, gitUri, {
...args,
branchOrTag: branchOrTag.branchOrTag,
branchOrTag: branchOrTag.item,
goBackCommand: currentCommand
} as DiffWithRevisionCommandArgs);
}
Expand Down
28 changes: 13 additions & 15 deletions src/commands/openBranchInRemote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { BranchesQuickPick, CommandQuickPickItem } from '../quickpicks';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import {
ActiveEditorCommand,
command,
Expand Down Expand Up @@ -53,21 +53,19 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
if (args.branch === undefined) {
args = { ...args };

const branches = (await Container.git.getBranches(repoPath)).filter(b => b.tracking !== undefined);
if (branches.length > 1) {
const pick = await BranchesQuickPick.show(
branches,
`Open which branch on remote${GlyphChars.Ellipsis}`
);
if (pick === undefined) return undefined;
const pick = await new BranchesAndTagsQuickPick(repoPath).show(
`Open which branch on remote${GlyphChars.Ellipsis}`,
{
autoPick: true,
filters: {
branches: b => b.tracking !== undefined
},
include: 'branches'
}
);
if (pick === undefined || pick instanceof CommandQuickPickItem) return undefined;

if (pick instanceof CommandQuickPickItem) return undefined;

args.branch = pick.branch.name;
}
else if (branches.length === 1) {
args.branch = branches[0].name;
}
args.branch = pick.item.name;
}

const remotes = await Container.git.getRemotes(repoPath);
Expand Down
35 changes: 15 additions & 20 deletions src/commands/openFileInRemote.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict';
import { __await } from 'tslib';
import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { BranchesQuickPick, CommandQuickPickItem } from '../quickpicks';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import {
ActiveEditorCommand,
command,
Expand Down Expand Up @@ -54,27 +55,21 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
if (args.branch === undefined) {
const branch = await Container.git.getBranch(gitUri.repoPath);
if (branch === undefined || branch.tracking === undefined) {
const branches = (await Container.git.getBranches(gitUri.repoPath)).filter(
b => b.tracking !== undefined
const pick = await new BranchesAndTagsQuickPick(gitUri.repoPath).show(
args.clipboard
? `Copy url for ${gitUri.getRelativePath()} to clipboard for which branch${GlyphChars.Ellipsis}`
: `Open ${gitUri.getRelativePath()} on remote for which branch${GlyphChars.Ellipsis}`,
{
autoPick: true,
filters: {
branches: b => b.tracking !== undefined
},
include: 'branches'
}
);
if (branches.length > 1) {
const pick = await BranchesQuickPick.show(
branches,
args.clipboard
? `Copy url for ${gitUri.getRelativePath()} to clipboard for which branch${
GlyphChars.Ellipsis
}`
: `Open ${gitUri.getRelativePath()} on remote for which branch${GlyphChars.Ellipsis}`
);
if (pick === undefined) return undefined;
if (pick === undefined || pick instanceof CommandQuickPickItem) return undefined;

if (pick instanceof CommandQuickPickItem) return undefined;

args.branch = pick.branch.name;
}
else if (branches.length === 1) {
args.branch = branches[0].name;
}
args.branch = pick.item.name;
}
else {
args.branch = branch.name;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openFileRevision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand {

return commands.executeCommand(Commands.OpenFileRevision, gitUri, {
...args,
branchOrTag: branchOrTag.branchOrTag,
branchOrTag: branchOrTag.item,
goBackCommand: currentCommand
} as OpenFileRevisionCommandArgs);
}
Expand Down
17 changes: 9 additions & 8 deletions src/commands/showQuickBranchHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Container } from '../container';
import { GitLog, GitUri } from '../git/gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickpicks';
import { BranchesAndTagsQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickpicks';
import { Strings } from '../system';
import { ActiveEditorCachedCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
Expand Down Expand Up @@ -46,8 +46,6 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
if (!repoPath) return undefined;

if (args.branch === undefined) {
const branches = await Container.git.getBranches(repoPath);

let goBackCommand;
if (!(await Container.git.getRepoPathOrActive(uri, editor))) {
goBackCommand = new CommandQuickPickItem(
Expand All @@ -60,14 +58,17 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
);
}

const pick = await BranchesQuickPick.show(branches, `Show history for branch${GlyphChars.Ellipsis}`, {
goBackCommand: goBackCommand
});
const pick = await new BranchesAndTagsQuickPick(repoPath).show(
`Show history for branch${GlyphChars.Ellipsis}`,
{
goBack: goBackCommand,
include: 'branches'
}
);
if (pick === undefined) return undefined;

if (pick instanceof CommandQuickPickItem) return pick.execute();

args.branch = pick.branch.name;
args.branch = pick.item.name;
if (args.branch === undefined) return undefined;

progressCancellation = BranchHistoryQuickPick.showProgress(args.branch);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/showQuickFileHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
return commands.executeCommand(Commands.ShowQuickFileHistory, gitUri, {
...args,
log: undefined,
branchOrTag: branchOrTag.branchOrTag,
branchOrTag: branchOrTag.item,
goBackCommand: currentCommand
} as ShowQuickFileHistoryCommandArgs);
}
Expand Down
1 change: 0 additions & 1 deletion src/quickpicks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

export * from './quickpicks/branchesAndTagsQuickPick';
export * from './quickpicks/branchesQuickPick';
export * from './quickpicks/branchHistoryQuickPick';
export * from './quickpicks/commitFileQuickPick';
export * from './quickpicks/commitQuickPick';
Expand Down

0 comments on commit 87e214c

Please sign in to comment.