Browse Source

Closes #690 - reworks reference pickers

Removes "Branch or Tag" from all commands
Changes openFileRevisionFrom allow entering references
Fixes missing views.compare.selectForCompare from command palette
main
Eric Amodio 5 years ago
parent
commit
f2c2bad47e
28 changed files with 670 additions and 654 deletions
  1. +9
    -0
      CHANGELOG.md
  2. +6
    -6
      README.md
  3. +15
    -15
      package.json
  4. +3
    -3
      src/commands.ts
  5. +8
    -0
      src/commands/common.ts
  6. +16
    -9
      src/commands/diffBranchWith.ts
  7. +3
    -3
      src/commands/diffDirectory.ts
  8. +7
    -7
      src/commands/diffWithRef.ts
  9. +20
    -16
      src/commands/diffWithRevision.ts
  10. +2
    -2
      src/commands/openBranchInRemote.ts
  11. +2
    -2
      src/commands/openFileInRemote.ts
  12. +20
    -16
      src/commands/openFileRevision.ts
  13. +14
    -17
      src/commands/openFileRevisionFrom.ts
  14. +2
    -2
      src/commands/showQuickBranchHistory.ts
  15. +21
    -17
      src/commands/showQuickFileHistory.ts
  16. +5
    -0
      src/git/models/models.ts
  17. +1
    -1
      src/quickpicks.ts
  18. +22
    -27
      src/quickpicks/commonQuickPicks.ts
  19. +2
    -6
      src/quickpicks/fileHistoryQuickPick.ts
  20. +17
    -26
      src/quickpicks/referencesQuickPick.ts
  21. +7
    -11
      src/views/nodes/compareNode.ts
  22. +2
    -2
      src/views/nodes/comparePickerNode.ts
  23. +3
    -3
      src/views/nodes/fileHistoryTrackerNode.ts
  24. +3
    -3
      src/views/nodes/lineHistoryTrackerNode.ts

+ 9
- 0
CHANGELOG.md View File

@ -25,14 +25,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Changed ### Changed
- Changes _Open Revision from..._ (`gitlens.openFileRevisionFrom`) command to allow entering references
- Improves the behavior of the _Show More Commits_ & _Show More Results_ commands - no longer loses the context of the last selected item before showing more - Improves the behavior of the _Show More Commits_ & _Show More Results_ commands - no longer loses the context of the last selected item before showing more
- Improves the behavior of the _Open Changes with Next Revision_ (`gitlens.diffWithNext`) command when in the diff editor - Improves the behavior of the _Open Changes with Next Revision_ (`gitlens.diffWithNext`) command when in the diff editor
- Improves the behavior of the _Open Changes with Previous Revision_ (`gitlens.diffWithPrevious`) command when in the diff editor - Improves the behavior of the _Open Changes with Previous Revision_ (`gitlens.diffWithPrevious`) command when in the diff editor
- Improves the behavior of the _Open Changes with Working File_ (`gitlens.diffWithWorking`) command when in the diff editor - Improves the behavior of the _Open Changes with Working File_ (`gitlens.diffWithWorking`) command when in the diff editor
- Renames _Compare HEAD with Branch or Tag..._ (`gitlens.diffHeadWithBranch`) command to _Compare HEAD with..._ (`gitlens.diffHeadWith`)
- Renames _Compare Working Tree with Branch or Tag..._ (`gitlens.diffWorkingWithBranch`) command to _Compare Working Tree with..._ (`gitlens.diffWorkingWith`)
- Renames _Open Changes with Branch or Tag..._ (`gitlens.diffWithBranch`) command to _Open Changes with..._ (`gitlens.diffWithRef`)
- Renames _Open Revision from Branch or Tag..._ (`gitlens.openFileRevisionFromBranch`) command to _Open Revision from..._ (`gitlens.openFileRevisionFrom`)
- Renames _Compare Branch or Tag with..._ (`gitlens.views.compare.selectForCompare`) command to _Compare References..._ (`gitlens.views.compare.selectForCompare`)
- Renames _Choose from Branch or Tag History..._ quick pick item to _Show File History from..._ for better clarity and to reflect that references are now allowed
- Updates the invite link to the [VS Code Development Community Slack](https://vscode-slack.amod.io) - Updates the invite link to the [VS Code Development Community Slack](https://vscode-slack.amod.io)
### Removed ### Removed
- Removes the requirement of prefixing reference comparisons with `#` — closes [#690](https://github.com/eamodio/vscode-gitlens/issues/690)
- Removes the automatic suspension of the current line blame annotations while debugging — closes [#382](https://github.com/eamodio/vscode-gitlens/issues/382) - Removes the automatic suspension of the current line blame annotations while debugging — closes [#382](https://github.com/eamodio/vscode-gitlens/issues/382)
### Fixed ### Fixed
@ -41,6 +49,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#683](https://github.com/eamodio/vscode-gitlens/issues/683) - log.showSignature leads to stray files being displayed - Fixes [#683](https://github.com/eamodio/vscode-gitlens/issues/683) - log.showSignature leads to stray files being displayed
- Fixes [#691](https://github.com/eamodio/vscode-gitlens/issues/691) - Auto-expand tree view on Swap Comparison - Fixes [#691](https://github.com/eamodio/vscode-gitlens/issues/691) - Auto-expand tree view on Swap Comparison
- Fixes the behavior of the _Open Line Changes with Previous Revision_ (`gitlens.diffLineWithPrevious`) command to follow the line history much better - Fixes the behavior of the _Open Line Changes with Previous Revision_ (`gitlens.diffLineWithPrevious`) command to follow the line history much better
- Fixes missing _Compare References..._ (`gitlens.views.compare.selectForCompare`) from the command palette
## [9.5.1] - 2019-02-13 ## [9.5.1] - 2019-02-13

+ 6
- 6
README.md View File

@ -442,7 +442,7 @@ The search commits view provides the following features,
A [customizable](#compare-view-settings- 'Jump to the Compare view settings') view to visualize comparisons between branches, tags, commits, and more A [customizable](#compare-view-settings- 'Jump to the Compare view settings') view to visualize comparisons between branches, tags, commits, and more
- A toolbar provides quick access to the _Compare Branch or Tag with..._, _Keep Results_, _Clear Results_, and _Refresh_ commands
- A toolbar provides quick access to the _Compare with..._, _Keep Results_, _Clear Results_, and _Refresh_ commands
- A context menu provides _Automatic Layout_, _List Layout_, _Tree Layout_, _Open Settings_ commands - A context menu provides _Automatic Layout_, _List Layout_, _Tree Layout_, _Open Settings_ commands
The compare view provides the following features, The compare view provides the following features,
@ -593,13 +593,13 @@ The compare view provides the following features,
- Provides easy access to the following comparison commands via the `Command Palette` as well as in context via the many provided quick pick menus - Provides easy access to the following comparison commands via the `Command Palette` as well as in context via the many provided quick pick menus
- Adds a _Directory Compare Working Tree with..._ command (`gitlens.diffDirectory`) to open the configured Git difftool to compare the working tree with the selected branch or tag
- Adds a _Directory Compare Working Tree with..._ command (`gitlens.diffDirectory`) to open the configured Git difftool to compare the working tree with the selected reference
- Adds a _Compare HEAD with Branch or Tag..._ command (`gitlens.diffHeadWithBranch`) to compare the index (HEAD) with the selected branch or tag
- Adds a _Compare HEAD with..._ command (`gitlens.diffHeadWith`) to compare the index (HEAD) with the selected reference
- Adds a _Compare Working Tree with Branch or Tag..._ command (`gitlens.diffWorkingWithBranch`) to compare the working tree with the selected branch or tag
- Adds a _Compare Working Tree with..._ command (`gitlens.diffWorkingWith`) to compare the working tree with the selected reference
- Adds an _Open Changes with Branch or Tag..._ command (`gitlens.diffWithBranch`) to compare the current file with the same file on the selected branch or tag
- Adds an _Open Changes with..._ command (`gitlens.diffWithRef`) to compare the current file with the same file on the selected reference
- Adds an _Open Changes with Next Revision_ command (`gitlens.diffWithNext`) with a shortcut of `alt+.` to compare the current file/diff with the next commit revision - Adds an _Open Changes with Next Revision_ command (`gitlens.diffWithNext`) with a shortcut of `alt+.` to compare the current file/diff with the next commit revision
@ -625,7 +625,7 @@ The compare view provides the following features,
- Adds an _Open Revision..._ command (`gitlens.openFileRevision`) to open the selected revision for the current file - Adds an _Open Revision..._ command (`gitlens.openFileRevision`) to open the selected revision for the current file
- Adds an _Open Revision from Branch or Tag..._ command (`gitlens.openFileRevisionFromBranch`) to open the revision of the current file from the selected branch
- Adds an _Open Revision from..._ command (`gitlens.openFileRevisionFrom`) to open the revision of the current file from the selected reference
- Adds an _Open Changes (with difftool)_ command (`gitlens.externalDiff`) to the source control group and source control resource context menus to open the changes of a file or set of files with the configured git difftool - Adds an _Open Changes (with difftool)_ command (`gitlens.externalDiff`) to the source control group and source control resource context menus to open the changes of a file or set of files with the configured git difftool

+ 15
- 15
package.json View File

@ -1834,18 +1834,18 @@
"category": "GitLens" "category": "GitLens"
}, },
{ {
"command": "gitlens.diffHeadWithBranch",
"title": "Compare HEAD with Branch or Tag...",
"command": "gitlens.diffHeadWith",
"title": "Compare HEAD with...",
"category": "GitLens" "category": "GitLens"
}, },
{ {
"command": "gitlens.diffWorkingWithBranch",
"title": "Compare Working Tree with Branch or Tag...",
"command": "gitlens.diffWorkingWith",
"title": "Compare Working Tree with...",
"category": "GitLens" "category": "GitLens"
}, },
{ {
"command": "gitlens.diffWithBranch",
"title": "Open Changes with Branch or Tag...",
"command": "gitlens.diffWithRef",
"title": "Open Changes with...",
"category": "GitLens" "category": "GitLens"
}, },
{ {
@ -2138,8 +2138,8 @@
"category": "GitLens" "category": "GitLens"
}, },
{ {
"command": "gitlens.openFileRevisionFromBranch",
"title": "Open Revision from Branch or Tag...",
"command": "gitlens.openFileRevisionFrom",
"title": "Open Revision from...",
"category": "GitLens" "category": "GitLens"
}, },
{ {
@ -2704,7 +2704,7 @@
}, },
{ {
"command": "gitlens.views.compare.selectForCompare", "command": "gitlens.views.compare.selectForCompare",
"title": "Compare Branch or Tag with...",
"title": "Compare References...",
"category": "GitLens", "category": "GitLens",
"icon": { "icon": {
"dark": "images/dark/icon-compare-refs.svg", "dark": "images/dark/icon-compare-refs.svg",
@ -2904,15 +2904,15 @@
"when": "gitlens:enabled" "when": "gitlens:enabled"
}, },
{ {
"command": "gitlens.diffHeadWithBranch",
"command": "gitlens.diffHeadWith",
"when": "gitlens:enabled" "when": "gitlens:enabled"
}, },
{ {
"command": "gitlens.diffWorkingWithBranch",
"command": "gitlens.diffWorkingWith",
"when": "gitlens:enabled" "when": "gitlens:enabled"
}, },
{ {
"command": "gitlens.diffWithBranch",
"command": "gitlens.diffWithRef",
"when": "gitlens:activeFileStatus =~ /tracked/" "when": "gitlens:activeFileStatus =~ /tracked/"
}, },
{ {
@ -3088,7 +3088,7 @@
"when": "gitlens:activeFileStatus =~ /tracked/" "when": "gitlens:activeFileStatus =~ /tracked/"
}, },
{ {
"command": "gitlens.openFileRevisionFromBranch",
"command": "gitlens.openFileRevisionFrom",
"when": "gitlens:activeFileStatus =~ /tracked/" "when": "gitlens:activeFileStatus =~ /tracked/"
}, },
{ {
@ -3421,7 +3421,7 @@
}, },
{ {
"command": "gitlens.views.compare.selectForCompare", "command": "gitlens.views.compare.selectForCompare",
"when": "gitlens:enabled && gitlens.views.compare.enabled"
"when": "gitlens:enabled && config.gitlens.views.compare.enabled"
}, },
{ {
"command": "gitlens.views.compare.clear", "command": "gitlens.views.compare.clear",
@ -3758,7 +3758,7 @@
"group": "1_gitlens@1" "group": "1_gitlens@1"
}, },
{ {
"command": "gitlens.diffWithBranch",
"command": "gitlens.diffWithRef",
"when": "gitlens:enabled && config.gitlens.menus.scmItem.compare", "when": "gitlens:enabled && config.gitlens.menus.scmItem.compare",
"group": "1_gitlens@2" "group": "1_gitlens@2"
}, },

+ 3
- 3
src/commands.ts View File

@ -6,14 +6,14 @@ export * from './commands/common';
export * from './commands/copyMessageToClipboard'; export * from './commands/copyMessageToClipboard';
export * from './commands/copyRemoteFileUrlToClipboard'; export * from './commands/copyRemoteFileUrlToClipboard';
export * from './commands/copyShaToClipboard'; export * from './commands/copyShaToClipboard';
export * from './commands/diffBranchWithBranch';
export * from './commands/diffBranchWith';
export * from './commands/diffDirectory'; export * from './commands/diffDirectory';
export * from './commands/diffLineWithPrevious'; export * from './commands/diffLineWithPrevious';
export * from './commands/diffLineWithWorking'; export * from './commands/diffLineWithWorking';
export * from './commands/diffWith'; export * from './commands/diffWith';
export * from './commands/diffWithBranch';
export * from './commands/diffWithNext'; export * from './commands/diffWithNext';
export * from './commands/diffWithPrevious'; export * from './commands/diffWithPrevious';
export * from './commands/diffWithRef';
export * from './commands/diffWithRevision'; export * from './commands/diffWithRevision';
export * from './commands/diffWithWorking'; export * from './commands/diffWithWorking';
export * from './commands/externalDiff'; export * from './commands/externalDiff';
@ -23,7 +23,7 @@ export * from './commands/openChangedFiles';
export * from './commands/openCommitInRemote'; export * from './commands/openCommitInRemote';
export * from './commands/openFileInRemote'; export * from './commands/openFileInRemote';
export * from './commands/openFileRevision'; export * from './commands/openFileRevision';
export * from './commands/openFileRevisionFromBranch';
export * from './commands/openFileRevisionFrom';
export * from './commands/openInRemote'; export * from './commands/openInRemote';
export * from './commands/openRepoInRemote'; export * from './commands/openRepoInRemote';
export * from './commands/openWorkingFile'; export * from './commands/openWorkingFile';

+ 8
- 0
src/commands/common.ts View File

@ -31,11 +31,17 @@ export enum Commands {
CopyShaToClipboard = 'gitlens.copyShaToClipboard', CopyShaToClipboard = 'gitlens.copyShaToClipboard',
DiffDirectory = 'gitlens.diffDirectory', DiffDirectory = 'gitlens.diffDirectory',
DiffDirectoryWithHead = 'gitlens.diffDirectoryWithHead', DiffDirectoryWithHead = 'gitlens.diffDirectoryWithHead',
DiffHeadWith = 'gitlens.diffHeadWith',
// DEPRECATED
DiffHeadWithBranch = 'gitlens.diffHeadWithBranch', DiffHeadWithBranch = 'gitlens.diffHeadWithBranch',
DiffWorkingWith = 'gitlens.diffWorkingWith',
// DEPRECATED
DiffWorkingWithBranch = 'gitlens.diffWorkingWithBranch', DiffWorkingWithBranch = 'gitlens.diffWorkingWithBranch',
ExternalDiffAll = 'gitlens.externalDiffAll', ExternalDiffAll = 'gitlens.externalDiffAll',
DiffWith = 'gitlens.diffWith', DiffWith = 'gitlens.diffWith',
// DEPRECATED
DiffWithBranch = 'gitlens.diffWithBranch', DiffWithBranch = 'gitlens.diffWithBranch',
DiffWithRef = 'gitlens.diffWithRef',
DiffWithNext = 'gitlens.diffWithNext', DiffWithNext = 'gitlens.diffWithNext',
DiffWithNextInDiff = 'gitlens.diffWithNextInDiff', DiffWithNextInDiff = 'gitlens.diffWithNextInDiff',
DiffWithPrevious = 'gitlens.diffWithPrevious', DiffWithPrevious = 'gitlens.diffWithPrevious',
@ -53,6 +59,8 @@ export enum Commands {
OpenCommitInRemote = 'gitlens.openCommitInRemote', OpenCommitInRemote = 'gitlens.openCommitInRemote',
OpenFileInRemote = 'gitlens.openFileInRemote', OpenFileInRemote = 'gitlens.openFileInRemote',
OpenFileRevision = 'gitlens.openFileRevision', OpenFileRevision = 'gitlens.openFileRevision',
OpenFileRevisionFrom = 'gitlens.openFileRevisionFrom',
// DEPRECATED
OpenFileRevisionFromBranch = 'gitlens.openFileRevisionFromBranch', OpenFileRevisionFromBranch = 'gitlens.openFileRevisionFromBranch',
OpenInRemote = 'gitlens.openInRemote', OpenInRemote = 'gitlens.openInRemote',
OpenRepoInRemote = 'gitlens.openRepoInRemote', OpenRepoInRemote = 'gitlens.openRepoInRemote',

src/commands/diffBranchWithBranch.ts → src/commands/diffBranchWith.ts View File

@ -4,7 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { import {
ActiveEditorCommand, ActiveEditorCommand,
command, command,
@ -14,23 +14,30 @@ import {
getRepoPathOrActiveOrPrompt getRepoPathOrActiveOrPrompt
} from './common'; } from './common';
export interface DiffBranchWithBranchCommandArgs {
export interface DiffBranchWithCommandArgs {
ref1?: string; ref1?: string;
ref2?: string; ref2?: string;
} }
@command() @command()
export class DiffBranchWithBranchCommand extends ActiveEditorCommand {
export class DiffBranchWithCommand extends ActiveEditorCommand {
constructor() { constructor() {
super([Commands.DiffHeadWithBranch, Commands.DiffWorkingWithBranch]);
super([
Commands.DiffHeadWith,
Commands.DiffWorkingWith,
Commands.DiffHeadWithBranch,
Commands.DiffWorkingWithBranch
]);
} }
protected preExecute(context: CommandContext, args: DiffBranchWithBranchCommandArgs = {}) {
protected preExecute(context: CommandContext, args: DiffBranchWithCommandArgs = {}) {
switch (context.command) { switch (context.command) {
case Commands.DiffHeadWith:
case Commands.DiffHeadWithBranch: case Commands.DiffHeadWithBranch:
args.ref2 = 'HEAD'; args.ref2 = 'HEAD';
break; break;
case Commands.DiffWorkingWith:
case Commands.DiffWorkingWithBranch: case Commands.DiffWorkingWithBranch:
args.ref2 = ''; args.ref2 = '';
break; break;
@ -39,7 +46,7 @@ export class DiffBranchWithBranchCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args); return this.execute(context.editor, context.uri, args);
} }
async execute(editor?: TextEditor, uri?: Uri, args: DiffBranchWithBranchCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args: DiffBranchWithCommandArgs = {}) {
if (args.ref2 === undefined) return undefined; if (args.ref2 === undefined) return undefined;
uri = getCommandUri(uri, editor); uri = getCommandUri(uri, editor);
@ -48,7 +55,7 @@ export class DiffBranchWithBranchCommand extends ActiveEditorCommand {
const repoPath = await getRepoPathOrActiveOrPrompt( const repoPath = await getRepoPathOrActiveOrPrompt(
uri, uri,
editor, editor,
`Compare with branch or tag in which repository${GlyphChars.Ellipsis}`
`Compare in which repository${GlyphChars.Ellipsis}`
); );
if (!repoPath) return undefined; if (!repoPath) return undefined;
@ -66,8 +73,8 @@ export class DiffBranchWithBranchCommand extends ActiveEditorCommand {
break; break;
} }
const pick = await new BranchesAndTagsQuickPick(repoPath).show(placeHolder, {
allowCommitId: true
const pick = await new ReferencesQuickPick(repoPath).show(placeHolder, {
allowEnteringRefs: true
}); });
if (pick === undefined) return undefined; if (pick === undefined) return undefined;

+ 3
- 3
src/commands/diffDirectory.ts View File

@ -4,7 +4,7 @@ import { BuiltInCommands, GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { CompareResultsNode } from '../views/nodes'; import { CompareResultsNode } from '../views/nodes';
import { import {
ActiveEditorCommand, ActiveEditorCommand,
@ -71,9 +71,9 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
if (!args.ref1) { if (!args.ref1) {
args = { ...args }; args = { ...args };
const pick = await new BranchesAndTagsQuickPick(repoPath).show(
const pick = await new ReferencesQuickPick(repoPath).show(
`Compare Working Tree with${GlyphChars.Ellipsis}`, `Compare Working Tree with${GlyphChars.Ellipsis}`,
{ allowCommitId: true }
{ allowEnteringRefs: true }
); );
if (pick === undefined) return undefined; if (pick === undefined) return undefined;

src/commands/diffWithBranch.ts → src/commands/diffWithRef.ts View File

@ -5,12 +5,12 @@ import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitService, GitUri } from '../git/gitService'; import { GitService, GitUri } from '../git/gitService';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { Strings } from '../system'; import { Strings } from '../system';
import { ActiveEditorCommand, command, Commands, getCommandUri } from './common'; import { ActiveEditorCommand, command, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith'; import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithBranchCommandArgs {
export interface DiffWithRefCommandArgs {
line?: number; line?: number;
showOptions?: TextDocumentShowOptions; showOptions?: TextDocumentShowOptions;
@ -18,12 +18,12 @@ export interface DiffWithBranchCommandArgs {
} }
@command() @command()
export class DiffWithBranchCommand extends ActiveEditorCommand {
export class DiffWithRefCommand extends ActiveEditorCommand {
constructor() { constructor() {
super(Commands.DiffWithBranch);
super([Commands.DiffWithRef, Commands.DiffWithBranch]);
} }
async execute(editor?: TextEditor, uri?: Uri, args: DiffWithBranchCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args: DiffWithRefCommandArgs = {}) {
uri = getCommandUri(uri, editor); uri = getCommandUri(uri, editor);
if (uri == null) return undefined; if (uri == null) return undefined;
@ -35,10 +35,10 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
const gitUri = await GitUri.fromUri(uri); const gitUri = await GitUri.fromUri(uri);
if (!gitUri.repoPath) return Messages.showNoRepositoryWarningMessage('Unable to open file compare'); if (!gitUri.repoPath) return Messages.showNoRepositoryWarningMessage('Unable to open file compare');
const pick = await new BranchesAndTagsQuickPick(gitUri.repoPath).show(
const pick = await new ReferencesQuickPick(gitUri.repoPath).show(
`Compare ${paths.basename(gitUri.fsPath)} with${GlyphChars.Ellipsis}`, `Compare ${paths.basename(gitUri.fsPath)} with${GlyphChars.Ellipsis}`,
{ {
allowCommitId: true,
allowEnteringRefs: true,
goBack: args.goBackCommand goBack: args.goBackCommand
} }
); );

+ 20
- 16
src/commands/diffWithRevision.ts View File

@ -2,16 +2,16 @@
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode'; import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitBranch, GitTag, GitUri } from '../git/gitService';
import { GitBranch, GitReference, GitTag, GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { ChooseFromBranchesAndTagsQuickPickItem, CommandQuickPickItem, FileHistoryQuickPick } from '../quickpicks';
import { CommandQuickPickItem, FileHistoryQuickPick, ShowFileHistoryFromQuickPickItem } from '../quickpicks';
import { Iterables, Strings } from '../system'; import { Iterables, Strings } from '../system';
import { ActiveEditorCommand, command, Commands, getCommandUri } from './common'; import { ActiveEditorCommand, command, Commands, getCommandUri } from './common';
import { DiffWithCommandArgs } from './diffWith'; import { DiffWithCommandArgs } from './diffWith';
export interface DiffWithRevisionCommandArgs { export interface DiffWithRevisionCommandArgs {
branchOrTag?: GitBranch | GitTag;
reference?: GitBranch | GitTag | GitReference;
maxCount?: number; maxCount?: number;
line?: number; line?: number;
@ -37,7 +37,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
const gitUri = await GitUri.fromUri(uri); const gitUri = await GitUri.fromUri(uri);
const placeHolder = `Compare ${gitUri.getFormattedPath({ const placeHolder = `Compare ${gitUri.getFormattedPath({
suffix: args.branchOrTag ? ` (${args.branchOrTag.name})` : undefined
suffix: args.reference ? ` (${args.reference.name})` : undefined
})}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''} with revision${ })}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''} with revision${
GlyphChars.Ellipsis GlyphChars.Ellipsis
}`; }`;
@ -46,11 +46,11 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
try { try {
const log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, { const log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, {
maxCount: args.maxCount, maxCount: args.maxCount,
ref: (args.branchOrTag && args.branchOrTag.ref) || gitUri.sha
ref: (args.reference && args.reference.ref) || gitUri.sha
}); });
if (log === undefined) { if (log === undefined) {
if (args.branchOrTag) {
return window.showWarningMessage(`The file could not be found in ${args.branchOrTag.name}`);
if (args.reference) {
return window.showWarningMessage(`The file could not be found in ${args.reference.name}`);
} }
return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open history compare'); return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open history compare');
} }
@ -86,16 +86,20 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
} }
commandArgs = { ...args }; commandArgs = { ...args };
const icon =
args.reference instanceof GitTag
? '$(tag) '
: args.reference instanceof GitBranch
? '$(git-branch) '
: '';
const currentCommand = new CommandQuickPickItem( const currentCommand = new CommandQuickPickItem(
{ {
label: `go back ${GlyphChars.ArrowBack}`, label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${ description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${
GlyphChars.Space GlyphChars.Space
}$(file-text) ${gitUri.getFormattedPath()}${ }$(file-text) ${gitUri.getFormattedPath()}${
args.branchOrTag
? ` from ${GlyphChars.Space}${
args.branchOrTag instanceof GitTag ? '$(tag)' : '$(git-branch)'
} ${args.branchOrTag.name}`
args.reference
? ` from ${GlyphChars.Space}${icon}${args.reference.name}`
: gitUri.sha : gitUri.sha
? ` from ${GlyphChars.Space}$(git-commit) ${gitUri.shortSha}` ? ` from ${GlyphChars.Space}$(git-commit) ${gitUri.shortSha}`
: '' : ''
@ -125,14 +129,14 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
}); });
if (pick === undefined) return undefined; if (pick === undefined) return undefined;
if (pick instanceof ChooseFromBranchesAndTagsQuickPickItem) {
const branchOrTag = await pick.execute();
if (branchOrTag === undefined) return undefined;
if (branchOrTag instanceof CommandQuickPickItem) return branchOrTag.execute();
if (pick instanceof ShowFileHistoryFromQuickPickItem) {
const reference = await pick.execute();
if (reference === undefined) return undefined;
if (reference instanceof CommandQuickPickItem) return reference.execute();
commandArgs = { commandArgs = {
...args, ...args,
branchOrTag: branchOrTag.item
reference: reference.item
}; };
return commands.executeCommand(Commands.DiffWithRevision, gitUri, commandArgs); return commands.executeCommand(Commands.DiffWithRevision, gitUri, commandArgs);
} }

+ 2
- 2
src/commands/openBranchInRemote.ts View File

@ -4,7 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri, RemoteResourceType } from '../git/gitService'; import { GitUri, RemoteResourceType } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { import {
ActiveEditorCommand, ActiveEditorCommand,
command, command,
@ -53,7 +53,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
if (args.branch === undefined) { if (args.branch === undefined) {
args = { ...args }; args = { ...args };
const pick = await new BranchesAndTagsQuickPick(repoPath).show(
const pick = await new ReferencesQuickPick(repoPath).show(
`Open which branch on remote${GlyphChars.Ellipsis}`, `Open which branch on remote${GlyphChars.Ellipsis}`,
{ {
autoPick: true, autoPick: true,

+ 2
- 2
src/commands/openFileInRemote.ts View File

@ -4,7 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri, RemoteResourceType } from '../git/gitService'; import { GitUri, RemoteResourceType } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { import {
ActiveEditorCommand, ActiveEditorCommand,
command, command,
@ -80,7 +80,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
if (args.branch === undefined && args.sha === undefined) { if (args.branch === undefined && args.sha === undefined) {
const branch = await Container.git.getBranch(gitUri.repoPath); const branch = await Container.git.getBranch(gitUri.repoPath);
if (branch === undefined || branch.tracking === undefined) { if (branch === undefined || branch.tracking === undefined) {
const pick = await new BranchesAndTagsQuickPick(gitUri.repoPath).show(
const pick = await new ReferencesQuickPick(gitUri.repoPath).show(
args.clipboard args.clipboard
? `Copy url for ${gitUri.getRelativePath()} to clipboard for which branch${ ? `Copy url for ${gitUri.getRelativePath()} to clipboard for which branch${
GlyphChars.Ellipsis GlyphChars.Ellipsis

+ 20
- 16
src/commands/openFileRevision.ts View File

@ -3,15 +3,15 @@ import { CancellationTokenSource, commands, Range, TextDocumentShowOptions, Text
import { FileAnnotationType } from '../configuration'; import { FileAnnotationType } from '../configuration';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitBranch, GitTag, GitUri } from '../git/gitService';
import { GitBranch, GitReference, GitTag, GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { ChooseFromBranchesAndTagsQuickPickItem, CommandQuickPickItem, FileHistoryQuickPick } from '../quickpicks';
import { CommandQuickPickItem, FileHistoryQuickPick, ShowFileHistoryFromQuickPickItem } from '../quickpicks';
import { Iterables, Strings } from '../system'; import { Iterables, Strings } from '../system';
import { ActiveEditorCommand, command, Commands, getCommandUri, openEditor } from './common'; import { ActiveEditorCommand, command, Commands, getCommandUri, openEditor } from './common';
export interface OpenFileRevisionCommandArgs { export interface OpenFileRevisionCommandArgs {
branchOrTag?: GitBranch | GitTag;
reference?: GitBranch | GitTag | GitReference;
uri?: Uri; uri?: Uri;
maxCount?: number; maxCount?: number;
@ -69,7 +69,7 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand {
const gitUri = await GitUri.fromUri(uri); const gitUri = await GitUri.fromUri(uri);
const placeHolder = `Open revision of ${gitUri.getFormattedPath({ const placeHolder = `Open revision of ${gitUri.getFormattedPath({
suffix: args.branchOrTag ? ` (${args.branchOrTag.name})` : undefined
suffix: args.reference ? ` (${args.reference.name})` : undefined
})}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''}${ })}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''}${
GlyphChars.Ellipsis GlyphChars.Ellipsis
}`; }`;
@ -78,11 +78,11 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand {
const log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, { const log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, {
maxCount: args.maxCount, maxCount: args.maxCount,
ref: (args.branchOrTag && args.branchOrTag.ref) || gitUri.sha
ref: (args.reference && args.reference.ref) || gitUri.sha
}); });
if (log === undefined) { if (log === undefined) {
if (args.branchOrTag) {
return window.showWarningMessage(`The file could not be found in ${args.branchOrTag.name}`);
if (args.reference) {
return window.showWarningMessage(`The file could not be found in ${args.reference.name}`);
} }
return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open history compare'); return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open history compare');
} }
@ -117,16 +117,20 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand {
} }
commandArgs = { ...args }; commandArgs = { ...args };
const icon =
args.reference instanceof GitTag
? '$(tag) '
: args.reference instanceof GitBranch
? '$(git-branch) '
: '';
const currentCommand = new CommandQuickPickItem( const currentCommand = new CommandQuickPickItem(
{ {
label: `go back ${GlyphChars.ArrowBack}`, label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${ description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${
GlyphChars.Space GlyphChars.Space
}$(file-text) ${gitUri.getFormattedPath()}${ }$(file-text) ${gitUri.getFormattedPath()}${
args.branchOrTag
? ` from ${GlyphChars.Space}${
args.branchOrTag instanceof GitTag ? '$(tag)' : '$(git-branch)'
} ${args.branchOrTag.name}`
args.reference
? ` from ${GlyphChars.Space}${icon}${args.reference.name}`
: gitUri.sha : gitUri.sha
? ` from ${GlyphChars.Space}$(git-commit) ${gitUri.shortSha}` ? ` from ${GlyphChars.Space}$(git-commit) ${gitUri.shortSha}`
: '' : ''
@ -156,14 +160,14 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand {
}); });
if (pick === undefined) return undefined; if (pick === undefined) return undefined;
if (pick instanceof ChooseFromBranchesAndTagsQuickPickItem) {
const branchOrTag = await pick.execute();
if (branchOrTag === undefined) return undefined;
if (branchOrTag instanceof CommandQuickPickItem) return branchOrTag.execute();
if (pick instanceof ShowFileHistoryFromQuickPickItem) {
const reference = await pick.execute();
if (reference === undefined) return undefined;
if (reference instanceof CommandQuickPickItem) return reference.execute();
commandArgs = { commandArgs = {
...args, ...args,
branchOrTag: branchOrTag.item
reference: reference.item
}; };
return commands.executeCommand(Commands.OpenFileRevision, gitUri, commandArgs); return commands.executeCommand(Commands.OpenFileRevision, gitUri, commandArgs);
} }

src/commands/openFileRevisionFromBranch.ts → src/commands/openFileRevisionFrom.ts View File

@ -1,46 +1,43 @@
'use strict'; 'use strict';
import { Range, TextDocumentShowOptions, TextEditor, Uri } from 'vscode'; import { Range, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { GitBranch, GitTag, GitUri } from '../git/gitService';
import { BranchesAndTagsQuickPick, BranchQuickPickItem, TagQuickPickItem } from '../quickpicks';
import { GitBranch, GitReference, GitTag, GitUri } from '../git/gitService';
import { CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { Strings } from '../system'; import { Strings } from '../system';
import { ActiveEditorCommand, command, Commands, getCommandUri, openEditor } from './common'; import { ActiveEditorCommand, command, Commands, getCommandUri, openEditor } from './common';
export interface OpenFileRevisionFromBranchCommandArgs {
branchOrTag?: GitBranch | GitTag;
export interface OpenFileRevisionFromCommandArgs {
reference?: GitBranch | GitTag | GitReference;
line?: number; line?: number;
showOptions?: TextDocumentShowOptions; showOptions?: TextDocumentShowOptions;
} }
@command() @command()
export class OpenFileRevisionFromBranchCommand extends ActiveEditorCommand {
export class OpenFileRevisionFromCommand extends ActiveEditorCommand {
constructor() { constructor() {
super(Commands.OpenFileRevisionFromBranch);
super([Commands.OpenFileRevisionFrom, Commands.OpenFileRevisionFromBranch]);
} }
async execute(editor: TextEditor | undefined, uri?: Uri, args: OpenFileRevisionFromBranchCommandArgs = {}) {
async execute(editor: TextEditor | undefined, uri?: Uri, args: OpenFileRevisionFromCommandArgs = {}) {
uri = getCommandUri(uri, editor); uri = getCommandUri(uri, editor);
if (uri == null) return undefined; if (uri == null) return undefined;
const gitUri = await GitUri.fromUri(uri); const gitUri = await GitUri.fromUri(uri);
if (!gitUri.repoPath) return undefined; if (!gitUri.repoPath) return undefined;
if (args.branchOrTag === undefined) {
if (args.reference === undefined) {
const placeHolder = `Open revision of ${gitUri.getFormattedPath()}${ const placeHolder = `Open revision of ${gitUri.getFormattedPath()}${
gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : '' gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''
} from Branch or Tag${GlyphChars.Ellipsis}`;
} from${GlyphChars.Ellipsis}`;
const pick = await new BranchesAndTagsQuickPick(gitUri.repoPath).show(placeHolder, {
allowCommitId: false
const pick = await new ReferencesQuickPick(gitUri.repoPath).show(placeHolder, {
allowEnteringRefs: true
}); });
if (pick === undefined) return undefined; if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();
if (!(pick instanceof BranchQuickPickItem) && !(pick instanceof TagQuickPickItem)) {
return undefined;
}
args.branchOrTag = pick.item;
args.reference = pick.item;
} }
if (args.line !== undefined && args.line !== 0) { if (args.line !== undefined && args.line !== 0) {
@ -50,7 +47,7 @@ export class OpenFileRevisionFromBranchCommand extends ActiveEditorCommand {
args.showOptions.selection = new Range(args.line, 0, args.line, 0); args.showOptions.selection = new Range(args.line, 0, args.line, 0);
} }
return openEditor(GitUri.toRevisionUri(args.branchOrTag.ref, gitUri.fsPath, gitUri.repoPath), {
return openEditor(GitUri.toRevisionUri(args.reference.ref, gitUri.fsPath, gitUri.repoPath), {
...args.showOptions, ...args.showOptions,
rethrow: true rethrow: true
}); });

+ 2
- 2
src/commands/showQuickBranchHistory.ts View File

@ -5,7 +5,7 @@ import { Container } from '../container';
import { GitLog, GitUri } from '../git/gitService'; import { GitLog, GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickpicks';
import { BranchHistoryQuickPick, CommandQuickPickItem, ReferencesQuickPick } from '../quickpicks';
import { Strings } from '../system'; import { Strings } from '../system';
import { ActiveEditorCachedCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; import { ActiveEditorCachedCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails'; import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
@ -58,7 +58,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
); );
} }
const pick = await new BranchesAndTagsQuickPick(repoPath).show(
const pick = await new ReferencesQuickPick(repoPath).show(
`Show history for branch${GlyphChars.Ellipsis}`, `Show history for branch${GlyphChars.Ellipsis}`,
{ {
goBack: goBackCommand, goBack: goBackCommand,

+ 21
- 17
src/commands/showQuickFileHistory.ts View File

@ -3,13 +3,13 @@ import * as paths from 'path';
import { commands, Range, TextEditor, Uri, window } from 'vscode'; import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitBranch, GitLog, GitTag, GitUri } from '../git/gitService';
import { GitBranch, GitLog, GitReference, GitTag, GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages'; import { Messages } from '../messages';
import { import {
ChooseFromBranchesAndTagsQuickPickItem,
CommandQuickPickItem, CommandQuickPickItem,
FileHistoryQuickPick, FileHistoryQuickPick,
ShowFileHistoryFromQuickPickItem,
ShowFileHistoryInViewQuickPickItem ShowFileHistoryInViewQuickPickItem
} from '../quickpicks'; } from '../quickpicks';
import { Iterables, Strings } from '../system'; import { Iterables, Strings } from '../system';
@ -17,7 +17,7 @@ import { ActiveEditorCachedCommand, command, CommandContext, Commands, getComman
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails'; import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
export interface ShowQuickFileHistoryCommandArgs { export interface ShowQuickFileHistoryCommandArgs {
branchOrTag?: GitBranch | GitTag;
reference?: GitBranch | GitTag | GitReference;
log?: GitLog; log?: GitLog;
maxCount?: number; maxCount?: number;
range?: Range; range?: Range;
@ -57,7 +57,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
args = { ...args }; args = { ...args };
const placeHolder = `${gitUri.getFormattedPath({ const placeHolder = `${gitUri.getFormattedPath({
suffix: args.branchOrTag ? ` (${args.branchOrTag.name})` : undefined
suffix: args.reference ? ` (${args.reference.name})` : undefined
})}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''}`; })}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''}`;
const progressCancellation = FileHistoryQuickPick.showProgress(placeHolder); const progressCancellation = FileHistoryQuickPick.showProgress(placeHolder);
@ -67,11 +67,11 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
args.log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, { args.log = await Container.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, {
maxCount: args.maxCount, maxCount: args.maxCount,
range: args.range, range: args.range,
ref: (args.branchOrTag && args.branchOrTag.ref) || gitUri.sha
ref: (args.reference && args.reference.ref) || gitUri.sha
}); });
if (args.log === undefined) { if (args.log === undefined) {
if (args.branchOrTag) {
return window.showWarningMessage(`The file could not be found in ${args.branchOrTag.name}`);
if (args.reference) {
return window.showWarningMessage(`The file could not be found in ${args.reference.name}`);
} }
return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show file history'); return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show file history');
} }
@ -111,6 +111,12 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
} }
} }
const icon =
args.reference instanceof GitTag
? '$(tag) '
: args.reference instanceof GitBranch
? '$(git-branch) '
: '';
// Create a command to get back to where we are right now // Create a command to get back to where we are right now
const currentCommand = new CommandQuickPickItem( const currentCommand = new CommandQuickPickItem(
{ {
@ -118,10 +124,8 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${ description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${
GlyphChars.Space GlyphChars.Space
}$(file-text) ${paths.basename(gitUri.fsPath)}${ }$(file-text) ${paths.basename(gitUri.fsPath)}${
args.branchOrTag
? ` from ${GlyphChars.Space}${
args.branchOrTag instanceof GitTag ? '$(tag)' : '$(git-branch)'
} ${args.branchOrTag.name}`
args.reference
? ` from ${GlyphChars.Space}${icon}${args.reference.name}`
: gitUri.sha : gitUri.sha
? ` from ${GlyphChars.Space}$(git-commit) ${gitUri.shortSha}` ? ` from ${GlyphChars.Space}$(git-commit) ${gitUri.shortSha}`
: '' : ''
@ -152,21 +156,21 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
args.log !== undefined args.log !== undefined
? new ShowFileHistoryInViewQuickPickItem( ? new ShowFileHistoryInViewQuickPickItem(
gitUri, gitUri,
(args.branchOrTag && args.branchOrTag.ref) || gitUri.sha
(args.reference && args.reference.ref) || gitUri.sha
) )
: undefined : undefined
}); });
if (pick === undefined) return undefined; if (pick === undefined) return undefined;
if (pick instanceof ChooseFromBranchesAndTagsQuickPickItem) {
const branchOrTag = await pick.execute();
if (branchOrTag === undefined) return undefined;
if (branchOrTag instanceof CommandQuickPickItem) return branchOrTag.execute();
if (pick instanceof ShowFileHistoryFromQuickPickItem) {
const reference = await pick.execute();
if (reference === undefined) return undefined;
if (reference instanceof CommandQuickPickItem) return reference.execute();
const commandArgs: ShowQuickFileHistoryCommandArgs = { const commandArgs: ShowQuickFileHistoryCommandArgs = {
...args, ...args,
log: undefined, log: undefined,
branchOrTag: branchOrTag.item,
reference: reference.item,
goBackCommand: currentCommand goBackCommand: currentCommand
}; };
return commands.executeCommand(Commands.ShowQuickFileHistory, gitUri, commandArgs); return commands.executeCommand(Commands.ShowQuickFileHistory, gitUri, commandArgs);

+ 5
- 0
src/git/models/models.ts View File

@ -1,5 +1,10 @@
'use strict'; 'use strict';
export interface GitReference {
name: string;
ref: string;
}
export * from './blame'; export * from './blame';
export * from './blameCommit'; export * from './blameCommit';
export * from './branch'; export * from './branch';

+ 1
- 1
src/quickpicks.ts View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
export * from './quickpicks/branchesAndTagsQuickPick';
export * from './quickpicks/branchHistoryQuickPick'; export * from './quickpicks/branchHistoryQuickPick';
export * from './quickpicks/commitFileQuickPick'; export * from './quickpicks/commitFileQuickPick';
export * from './quickpicks/commitQuickPick'; export * from './quickpicks/commitQuickPick';
@ -8,6 +7,7 @@ export * from './quickpicks/commitsQuickPick';
export * from './quickpicks/commonQuickPicks'; export * from './quickpicks/commonQuickPicks';
export * from './quickpicks/fileHistoryQuickPick'; export * from './quickpicks/fileHistoryQuickPick';
export * from './quickpicks/modesQuickPick'; export * from './quickpicks/modesQuickPick';
export * from './quickpicks/referencesQuickPick';
export * from './quickpicks/remotesQuickPick'; export * from './quickpicks/remotesQuickPick';
export * from './quickpicks/repositoriesQuickPick'; export * from './quickpicks/repositoriesQuickPick';
export * from './quickpicks/repoStatusQuickPick'; export * from './quickpicks/repoStatusQuickPick';

+ 22
- 27
src/quickpicks/commonQuickPicks.ts View File

@ -15,12 +15,7 @@ import { Container } from '../container';
import { GitLog, GitLogCommit, GitRepoSearchBy, GitStashCommit, GitUri } from '../git/gitService'; import { GitLog, GitLogCommit, GitRepoSearchBy, GitStashCommit, GitUri } from '../git/gitService';
import { KeyMapping, Keys } from '../keyboard'; import { KeyMapping, Keys } from '../keyboard';
import { Strings } from '../system'; import { Strings } from '../system';
import {
BranchesAndTagsQuickPick,
BranchQuickPickItem,
RefQuickPickItem,
TagQuickPickItem
} from './branchesAndTagsQuickPick';
import { ReferencesQuickPick, ReferencesQuickPickItem } from './referencesQuickPick';
export function getQuickPickIgnoreFocusOut() { export function getQuickPickIgnoreFocusOut() {
return !configuration.get<boolean>(configuration.name('advanced')('quickPick')('closeOnFocusOut').value); return !configuration.get<boolean>(configuration.name('advanced')('quickPick')('closeOnFocusOut').value);
@ -134,27 +129,6 @@ export class CommitQuickPickItem implemen
} }
} }
export class ChooseFromBranchesAndTagsQuickPickItem extends CommandQuickPickItem {
constructor(
private readonly repoPath: string,
private readonly placeHolder: string,
private readonly _goBack?: CommandQuickPickItem,
item: QuickPickItem = {
label: 'Choose from Branch or Tag History...',
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} shows list of branches and tags`
}
) {
super(item, undefined, undefined);
}
execute(): Promise<CommandQuickPickItem | BranchQuickPickItem | TagQuickPickItem | RefQuickPickItem | undefined> {
return new BranchesAndTagsQuickPick(this.repoPath).show(this.placeHolder, {
allowCommitId: true,
goBack: this._goBack
});
}
}
export class KeyCommandQuickPickItem extends CommandQuickPickItem { export class KeyCommandQuickPickItem extends CommandQuickPickItem {
constructor(command: Commands, args?: any[]) { constructor(command: Commands, args?: any[]) {
super({ label: '', description: '' }, command, args); super({ label: '', description: '' }, command, args);
@ -262,6 +236,27 @@ export class ShowCommitSearchResultsInViewQuickPickItem extends CommandQuickPick
} }
} }
export class ShowFileHistoryFromQuickPickItem extends CommandQuickPickItem {
constructor(
private readonly repoPath: string,
private readonly placeHolder: string,
private readonly _goBack?: CommandQuickPickItem,
item: QuickPickItem = {
label: 'Show File History from...',
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} shows an alternate file history`
}
) {
super(item, undefined, undefined);
}
execute(): Promise<CommandQuickPickItem | ReferencesQuickPickItem | undefined> {
return new ReferencesQuickPick(this.repoPath).show(this.placeHolder, {
allowEnteringRefs: true,
goBack: this._goBack
});
}
}
export class ShowFileHistoryInViewQuickPickItem extends CommandQuickPickItem { export class ShowFileHistoryInViewQuickPickItem extends CommandQuickPickItem {
constructor( constructor(
public readonly uri: GitUri, public readonly uri: GitUri,

+ 2
- 6
src/quickpicks/fileHistoryQuickPick.ts View File

@ -8,10 +8,10 @@ import { GitLog, GitUri, RemoteResource, RemoteResourceType } from '../git/gitSe
import { KeyNoopCommand } from '../keyboard'; import { KeyNoopCommand } from '../keyboard';
import { Iterables, Strings } from '../system'; import { Iterables, Strings } from '../system';
import { import {
ChooseFromBranchesAndTagsQuickPickItem,
CommandQuickPickItem, CommandQuickPickItem,
CommitQuickPickItem, CommitQuickPickItem,
getQuickPickIgnoreFocusOut, getQuickPickIgnoreFocusOut,
ShowFileHistoryFromQuickPickItem,
showQuickPickProgress showQuickPickProgress
} from './commonQuickPicks'; } from './commonQuickPicks';
import { OpenRemotesCommandQuickPickItem } from './remotesQuickPick'; import { OpenRemotesCommandQuickPickItem } from './remotesQuickPick';
@ -49,11 +49,7 @@ export class FileHistoryQuickPick {
let index = 0; let index = 0;
index++; index++;
items.splice(
0,
0,
new ChooseFromBranchesAndTagsQuickPickItem(log.repoPath, placeHolder, options.currentCommand)
);
items.splice(0, 0, new ShowFileHistoryFromQuickPickItem(log.repoPath, placeHolder, options.currentCommand));
if (options.showInViewCommand !== undefined) { if (options.showInViewCommand !== undefined) {
index++; index++;

src/quickpicks/branchesAndTagsQuickPick.ts → src/quickpicks/referencesQuickPick.ts View File

@ -2,7 +2,7 @@
import { CancellationToken, CancellationTokenSource, QuickPickItem, window } from 'vscode'; import { CancellationToken, CancellationTokenSource, QuickPickItem, window } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitBranch, GitService, GitTag } from '../git/gitService';
import { GitBranch, GitReference, GitService, GitTag } from '../git/gitService';
import { Functions } from '../system'; import { Functions } from '../system';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './commonQuickPicks'; import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './commonQuickPicks';
@ -23,7 +23,8 @@ export class RefQuickPickItem implements QuickPickItem {
} }
get item() { get item() {
return undefined;
const ref: GitReference = { name: this.ref, ref: this.ref };
return ref;
} }
get remote() { get remote() {
@ -68,7 +69,7 @@ export class TagQuickPickItem implements QuickPickItem {
description: string; description: string;
detail: string | undefined; detail: string | undefined;
constructor(public readonly tag: GitBranch | GitTag, checked?: boolean) {
constructor(public readonly tag: GitTag, checked?: boolean) {
this.label = `${checked ? `$(check)${GlyphChars.Space}` : GlyphChars.Space.repeat(4)} ${tag.name}`; this.label = `${checked ? `$(check)${GlyphChars.Space}` : GlyphChars.Space.repeat(4)} ${tag.name}`;
this.description = `${GlyphChars.Space.repeat(2)} tag`; this.description = `${GlyphChars.Space.repeat(2)} tag`;
} }
@ -90,10 +91,10 @@ export class TagQuickPickItem implements QuickPickItem {
} }
} }
export type BranchAndTagQuickPickResult = BranchQuickPickItem | TagQuickPickItem | RefQuickPickItem;
export type ReferencesQuickPickItem = BranchQuickPickItem | TagQuickPickItem | RefQuickPickItem;
export interface BranchesAndTagsQuickPickOptions {
allowCommitId?: boolean;
export interface ReferencesQuickPickOptions {
allowEnteringRefs?: boolean;
autoPick?: boolean; autoPick?: boolean;
checked?: string; checked?: string;
filters?: { filters?: {
@ -104,13 +105,13 @@ export interface BranchesAndTagsQuickPickOptions {
include?: 'branches' | 'tags' | 'all'; include?: 'branches' | 'tags' | 'all';
} }
export class BranchesAndTagsQuickPick {
export class ReferencesQuickPick {
constructor(public readonly repoPath: string | undefined) {} constructor(public readonly repoPath: string | undefined) {}
async show( async show(
placeHolder: string, placeHolder: string,
options: BranchesAndTagsQuickPickOptions = {}
): Promise<BranchAndTagQuickPickResult | CommandQuickPickItem | undefined> {
options: ReferencesQuickPickOptions = {}
): Promise<ReferencesQuickPickItem | CommandQuickPickItem | undefined> {
const cancellation = new CancellationTokenSource(); const cancellation = new CancellationTokenSource();
let scope; let scope;
@ -132,10 +133,10 @@ export class BranchesAndTagsQuickPick {
} }
let pick; let pick;
if (options.allowCommitId) {
placeHolder += `${GlyphChars.Space.repeat(3)}(use # to enter a commit id)`;
if (options.allowEnteringRefs) {
placeHolder += `${GlyphChars.Space.repeat(3)}(select or enter a reference)`;
const quickpick = window.createQuickPick<BranchAndTagQuickPickResult | CommandQuickPickItem>();
const quickpick = window.createQuickPick<ReferencesQuickPickItem | CommandQuickPickItem>();
quickpick.busy = true; quickpick.busy = true;
quickpick.enabled = false; quickpick.enabled = false;
quickpick.placeholder = placeHolder; quickpick.placeholder = placeHolder;
@ -146,26 +147,16 @@ export class BranchesAndTagsQuickPick {
quickpick.busy = false; quickpick.busy = false;
quickpick.enabled = true; quickpick.enabled = true;
pick = await new Promise<BranchAndTagQuickPickResult | CommandQuickPickItem | undefined>(resolve => {
pick = await new Promise<ReferencesQuickPickItem | CommandQuickPickItem | undefined>(resolve => {
cancellation.token.onCancellationRequested(() => quickpick.hide()); cancellation.token.onCancellationRequested(() => quickpick.hide());
quickpick.onDidHide(() => resolve(undefined)); quickpick.onDidHide(() => resolve(undefined));
quickpick.onDidChangeValue(value => {
quickpick.title =
value && value.startsWith('#')
? "Please enter a commit id (Press 'Enter' to confirm or 'Escape' to cancel)"
: undefined;
});
quickpick.onDidAccept(async () => { quickpick.onDidAccept(async () => {
if (quickpick.selectedItems.length === 0) { if (quickpick.selectedItems.length === 0) {
let ref = quickpick.value;
if (!ref || !ref.startsWith('#')) return;
ref = ref.substr(1);
quickpick.busy = true; quickpick.busy = true;
quickpick.enabled = false; quickpick.enabled = false;
const ref = quickpick.value;
if ( if (
this.repoPath === undefined || this.repoPath === undefined ||
(await Container.git.validateReference(this.repoPath, ref)) (await Container.git.validateReference(this.repoPath, ref))
@ -173,7 +164,7 @@ export class BranchesAndTagsQuickPick {
resolve(new RefQuickPickItem(ref)); resolve(new RefQuickPickItem(ref));
} }
else { else {
quickpick.title = 'You must enter a valid commit id';
quickpick.title = 'You must enter a valid reference';
quickpick.busy = false; quickpick.busy = false;
quickpick.enabled = true; quickpick.enabled = true;
return; return;
@ -219,7 +210,7 @@ export class BranchesAndTagsQuickPick {
} }
} }
private async getItems(options: BranchesAndTagsQuickPickOptions, token: CancellationToken) {
private async getItems(options: ReferencesQuickPickOptions, token: CancellationToken) {
const { checked, filters, goBack, include } = { include: 'all', ...options }; const { checked, filters, goBack, include } = { include: 'all', ...options };
let branches; let branches;

+ 7
- 11
src/views/nodes/compareNode.ts View File

@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { getRepoPathOrPrompt } from '../../commands'; import { getRepoPathOrPrompt } from '../../commands';
import { CommandContext, GlyphChars, NamedRef, setCommandContext } from '../../constants'; import { CommandContext, GlyphChars, NamedRef, setCommandContext } from '../../constants';
import { GitService } from '../../git/gitService'; import { GitService } from '../../git/gitService';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick } from '../../quickpicks';
import { debug, Functions, gate, Iterables, log } from '../../system'; import { debug, Functions, gate, Iterables, log } from '../../system';
import { CompareView } from '../compareView'; import { CompareView } from '../compareView';
import { MessageNode } from './common'; import { MessageNode } from './common';
@ -139,9 +139,9 @@ export class CompareNode extends ViewNode {
} }
if (ref === undefined) { if (ref === undefined) {
const pick = await new BranchesAndTagsQuickPick(repoPath).show(
const pick = await new ReferencesQuickPick(repoPath).show(
`Compare ${this.getRefName(this._selectedRef.ref)} with${GlyphChars.Ellipsis}`, `Compare ${this.getRefName(this._selectedRef.ref)} with${GlyphChars.Ellipsis}`,
{ allowCommitId: true }
{ allowEnteringRefs: true }
); );
if (pick === undefined || pick instanceof CommandQuickPickItem) return; if (pick === undefined || pick instanceof CommandQuickPickItem) return;
@ -158,19 +158,15 @@ export class CompareNode extends ViewNode {
async selectForCompare(repoPath?: string, ref?: string | NamedRef) { async selectForCompare(repoPath?: string, ref?: string | NamedRef) {
if (repoPath === undefined) { if (repoPath === undefined) {
repoPath = await getRepoPathOrPrompt(
undefined,
`Select branch or tag for compare in which repository${GlyphChars.Ellipsis}`
);
repoPath = await getRepoPathOrPrompt(undefined, `Compare in which repository${GlyphChars.Ellipsis}`);
} }
if (repoPath === undefined) return; if (repoPath === undefined) return;
let autoCompare = false; let autoCompare = false;
if (ref === undefined) { if (ref === undefined) {
const pick = await new BranchesAndTagsQuickPick(repoPath).show(
`Select branch or tag for compare${GlyphChars.Ellipsis}`,
{ allowCommitId: true }
);
const pick = await new ReferencesQuickPick(repoPath).show(`Compare${GlyphChars.Ellipsis}`, {
allowEnteringRefs: true
});
if (pick === undefined || pick instanceof CommandQuickPickItem) return; if (pick === undefined || pick instanceof CommandQuickPickItem) return;
ref = pick.ref; ref = pick.ref;

+ 2
- 2
src/views/nodes/comparePickerNode.ts View File

@ -35,9 +35,9 @@ export class ComparePickerNode extends ViewNode {
); );
item.contextValue = ResourceType.ComparePicker; item.contextValue = ResourceType.ComparePicker;
item.description = description; item.description = description;
item.tooltip = `Click to select branch or tag for compare${GlyphChars.Ellipsis}`;
item.tooltip = `Click to select or enter a reference for compare${GlyphChars.Ellipsis}`;
item.command = { item.command = {
title: `Select branch or tag for compare${GlyphChars.Ellipsis}`,
title: `Compare${GlyphChars.Ellipsis}`,
command: this.view.getQualifiedCommand('selectForCompare') command: this.view.getQualifiedCommand('selectForCompare')
}; };
} }

+ 3
- 3
src/views/nodes/fileHistoryTrackerNode.ts View File

@ -5,7 +5,7 @@ import { GlyphChars } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { GitCommitish, GitUri } from '../../git/gitService'; import { GitCommitish, GitUri } from '../../git/gitService';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick } from '../../quickpicks';
import { debug, Functions, gate, log } from '../../system'; import { debug, Functions, gate, log } from '../../system';
import { FileHistoryView } from '../fileHistoryView'; import { FileHistoryView } from '../fileHistoryView';
import { MessageNode } from './common'; import { MessageNode } from './common';
@ -68,10 +68,10 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
@gate() @gate()
@log() @log()
async changeBase() { async changeBase() {
const pick = await new BranchesAndTagsQuickPick(this.uri.repoPath!).show(
const pick = await new ReferencesQuickPick(this.uri.repoPath!).show(
`Change the file history base to${GlyphChars.Ellipsis}`, `Change the file history base to${GlyphChars.Ellipsis}`,
{ {
allowCommitId: true,
allowEnteringRefs: true,
checked: this._baseRef checked: this._baseRef
} }
); );

+ 3
- 3
src/views/nodes/lineHistoryTrackerNode.ts View File

@ -5,7 +5,7 @@ import { GlyphChars } from '../../constants';
import { Container } from '../../container'; import { Container } from '../../container';
import { GitCommitish, GitUri } from '../../git/gitService'; import { GitCommitish, GitUri } from '../../git/gitService';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../../quickpicks';
import { CommandQuickPickItem, ReferencesQuickPick } from '../../quickpicks';
import { debug, Functions, gate, log } from '../../system'; import { debug, Functions, gate, log } from '../../system';
import { LinesChangeEvent } from '../../trackers/gitLineTracker'; import { LinesChangeEvent } from '../../trackers/gitLineTracker';
import { LineHistoryView } from '../lineHistoryView'; import { LineHistoryView } from '../lineHistoryView';
@ -72,10 +72,10 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
@gate() @gate()
@log() @log()
async changeBase() { async changeBase() {
const pick = await new BranchesAndTagsQuickPick(this.uri.repoPath!).show(
const pick = await new ReferencesQuickPick(this.uri.repoPath!).show(
`Change the line history base to${GlyphChars.Ellipsis}`, `Change the line history base to${GlyphChars.Ellipsis}`,
{ {
allowCommitId: true,
allowEnteringRefs: true,
checked: this._base checked: this._base
} }
); );

Loading…
Cancel
Save