Przeglądaj źródła

Closes #237 - Adds single commit in results

main
Eric Amodio 7 lat temu
rodzic
commit
b4ecb701b2
7 zmienionych plików z 76 dodań i 10 usunięć
  1. +6
    -2
      CHANGELOG.md
  2. +3
    -3
      README.md
  3. +5
    -1
      src/quickPicks/commitDetails.ts
  4. +22
    -2
      src/quickPicks/common.ts
  5. +32
    -0
      src/views/commitResultsNode.ts
  6. +1
    -0
      src/views/explorerNodes.ts
  7. +7
    -2
      src/views/resultsExplorer.ts

+ 6
- 2
CHANGELOG.md Wyświetl plik

@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Added
- Adds semi-persistent results for commit operations, via the `Show Commit Details` command (`gitlens.showQuickCommitDetails`) in the `GitLens Results` view -- closes [#237](https://github.com/eamodio/vscode-gitlens/issues/237)
- Adds `Show in Results` option to the commit details quick pick menu to show the commit in the `GitLens Results` view
### Changed
- Improves startup performance and reduces package size
@ -55,12 +59,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds an all-new, on-demand `GitLens Results` view to the Explorer activity
- Provides semi-persistent results for commit search operations, via `Show Commit Search` command (`gitlens.showCommitSearch`), and file history operations, via `Show File History` command (`gitlens.showQuickFileHistory`)
- Provides semi-persistent results for commit search operations, via the `Show Commit Search` command (`gitlens.showCommitSearch`), and file history operations, via the `Show File History` command (`gitlens.showQuickFileHistory`)
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
- Provides semi-persistent results for revision comparison operations, via `Select for Compare` command (`gitlens.explorers.selectForCompare`) and `Compare with Selected` command (`gitlens.explorers.compareWithSelected`)
- Provides semi-persistent results for revision comparison operations, via the `Select for Compare` command (`gitlens.explorers.selectForCompare`) and the `Compare with Selected` command (`gitlens.explorers.compareWithSelected`)
- `Commits` node — provides a list of the commits between the compared revisions (branches or commits)
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands

+ 3
- 3
README.md Wyświetl plik

@ -210,12 +210,12 @@ While GitLens is highly customizable and provides many [configuration settings](
- Adds an on-demand, [customizable](#gitlens-results-view-settings) `GitLens Results` view to the Explorer activity
- Provides semi-persistent results for commit search operations, via Show Commit Search command (`gitlens.showCommitSearch`), and file history operations, via Show File History command (`gitlens.showQuickFileHistory`)
- Provides semi-persistent results for commit search operations, via the `Show Commit Search` command (`gitlens.showCommitSearch`), file history operations, via the `Show File History` command (`gitlens.showQuickFileHistory`), and commit operations, via the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
- Provides semi-persistent results for revision comparison operations, via `Select for Compare` command (`gitlens.explorers.selectForCompare`) and `Compare with Selected` command (`gitlens.explorers.compareWithSelected`)
- Provides semi-persistent results for revision comparison operations, via the `Select for Compare` command (`gitlens.explorers.selectForCompare`) and the `Compare with Selected` command (`gitlens.explorers.compareWithSelected`)
- `Commits` node — provides a list of the commits between the compared revisions (branches or commits)
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
@ -258,7 +258,7 @@ While GitLens is highly customizable and provides many [configuration settings](
![Commit Details Quick Pick Menu](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-commit-details.png)
- Quickly see the set of files changed in the commit, complete with status indicators for adds, changes, renames, and deletes
- Provides additional entries to `Open Commit in <remote-service>` when available, `Open Files`, `Open Revisions`, `Open Directory Compare with Previous Revision`, `Open Directory Compare with Working Tree`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`
- Provides additional entries to `Show in Results`, `Open Commit in <remote-service>` when available, `Open Files`, `Open Revisions`, `Open Directory Compare with Previous Revision`, `Open Directory Compare with Working Tree`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`
- Navigate back to the previous quick pick menu via `alt+left arrow`, if available
- Use the `alt+right arrow` shortcut on an entry to execute it without closing the quick pick menu, if possible — commands that open windows outside of VS Code will still close the quick pick menu unless [`"gitlens.advanced.quickPick.closeOnFocusOut": false`](#advanced-settings) is set
- Use the `alt+right arrow` shortcut on a file entry in the `Changed Files` section to preview the comparison of the current revision with the previous one

+ 5
- 1
src/quickPicks/commitDetails.ts Wyświetl plik

@ -2,7 +2,7 @@
import { Arrays, Iterables, Strings } from '../system';
import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode';
import { Commands, CopyMessageToClipboardCommandArgs, CopyShaToClipboardCommandArgs, DiffDirectoryCommandCommandArgs, DiffWithPreviousCommandArgs, ShowQuickCommitDetailsCommandArgs, StashApplyCommandArgs, StashDeleteCommandArgs } from '../commands';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem, QuickPickItem } from './common';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem, QuickPickItem, ShowCommitInResultsQuickPickItem } from './common';
import { GlyphChars } from '../constants';
import { getGitStatusOcticon, GitLog, GitLogCommit, GitService, GitStashCommit, GitStatusFile, GitStatusFileStatus, GitUri, IGitStatusFile, RemoteResource } from '../gitService';
import { Keyboard, KeyCommand, KeyNoopCommand, Keys } from '../keyboard';
@ -122,8 +122,12 @@ export class CommitDetailsQuickPick {
} as StashDeleteCommandArgs
])
);
items.splice(index++, 0, new ShowCommitInResultsQuickPickItem(commit));
}
else {
items.splice(index++, 0, new ShowCommitInResultsQuickPickItem(commit));
const remotes = (await git.getRemotes(commit.repoPath)).filter(r => r.provider !== undefined);
if (remotes.length) {
items.splice(index++, 0, new OpenRemotesCommandQuickPickItem(remotes, {

+ 22
- 2
src/quickPicks/common.ts Wyświetl plik

@ -174,6 +174,23 @@ export class CommitQuickPickItem implements QuickPickItem {
}
}
export class ShowCommitInResultsQuickPickItem extends CommandQuickPickItem {
constructor(
public readonly commit: GitLogCommit,
item: QuickPickItem = {
label: 'Show in Results',
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} displays commit in the GitLens Results view`
}
) {
super(item, undefined, undefined);
}
async execute(options: TextDocumentShowOptions = { preserveFocus: false, preview: false }): Promise<{} | undefined> {
ResultsExplorer.instance.showCommitInResults(this.commit);
return undefined;
}
}
export class ShowCommitsInResultsQuickPickItem extends CommandQuickPickItem {
constructor(
@ -181,7 +198,7 @@ export class ShowCommitsInResultsQuickPickItem extends CommandQuickPickItem {
public readonly resultsLabel: string | { label: string, resultsType?: { singular: string, plural: string } },
item: QuickPickItem = {
label: 'Show in Results',
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} displays results in the GitLens Results view`
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} displays commits in the GitLens Results view`
}
) {
super(item, undefined, undefined);
@ -198,7 +215,10 @@ export class ShowCommitsSearchInResultsQuickPickItem extends ShowCommitsInResult
constructor(
public readonly results: GitLog,
public readonly search: string,
item?: QuickPickItem
item: QuickPickItem = {
label: 'Show in Results',
description: `${Strings.pad(GlyphChars.Dash, 2, 2)} displays results in the GitLens Results view`
}
) {
super(results, { label: search }, item);
}

+ 32
- 0
src/views/commitResultsNode.ts Wyświetl plik

@ -0,0 +1,32 @@
'use strict';
import { Strings } from '../system';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitNode } from './commitNode';
import { GlyphChars } from '../constants';
import { Explorer, ExplorerNode, MessageNode, ResourceType } from './explorerNode';
import { CommitFormatter, GitLogCommit } from '../gitService';
export class CommitResultsNode extends ExplorerNode {
constructor(
readonly commit: GitLogCommit,
private readonly explorer: Explorer,
private readonly contextValue: ResourceType = ResourceType.Results
) {
super(commit.toGitUri());
}
async getChildren(): Promise<ExplorerNode[]> {
const children = await new CommitNode(this.commit, this.explorer).getChildren();
// Since we can't control the tooltip separately from the message (see https://github.com/Microsoft/vscode/issues/32012), don't truncate it
children.splice(0, 0, new MessageNode(CommitFormatter.fromTemplate('${message}', this.commit, { truncateMessageAtNewLine: false })));
return children;
}
async getTreeItem(): Promise<TreeItem> {
const label = CommitFormatter.fromTemplate(`Commit \${sha} ${Strings.pad(GlyphChars.Dash, 1, 1)} \${authorAgo}`, this.commit, this.explorer.git.config.defaultDateFormat);
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);
item.contextValue = this.contextValue;
return item;
}
}

+ 1
- 0
src/views/explorerNodes.ts Wyświetl plik

@ -6,6 +6,7 @@ export * from './branchesNode';
export * from './branchNode';
export * from './commitFileNode';
export * from './commitNode';
export * from './commitResultsNode';
export * from './commitsNode';
export * from './commitsResultsNode';
export * from './comparisionResultsNode';

+ 7
- 2
src/views/resultsExplorer.ts Wyświetl plik

@ -4,8 +4,8 @@ import { commands, ConfigurationChangeEvent, ConfigurationTarget, Event, EventEm
import { configuration, ExplorerFilesLayout, IExplorerConfig } from '../configuration';
import { CommandContext, setCommandContext, WorkspaceState } from '../constants';
import { ExplorerCommands, RefreshNodeCommandArgs } from './explorerCommands';
import { CommitsResultsNode, ComparisionResultsNode, ExplorerNode, MessageNode, RefreshReason, ResourceType } from './explorerNodes';
import { clearGravatarCache, GitLog, GitService } from '../gitService';
import { CommitResultsNode, CommitsResultsNode, ComparisionResultsNode, ExplorerNode, MessageNode, RefreshReason, ResourceType } from './explorerNodes';
import { clearGravatarCache, GitLog, GitLogCommit, GitService } from '../gitService';
import { Logger } from '../logger';
export * from './explorerNodes';
@ -134,6 +134,11 @@ export class ResultsExplorer implements TreeDataProvider {
setCommandContext(CommandContext.ResultsExplorer, true);
}
showCommitInResults(commit: GitLogCommit) {
this.addResults(new CommitResultsNode(commit, this));
setCommandContext(CommandContext.ResultsExplorer, true);
}
showCommitsInResults(results: GitLog, resultsLabel: string | { label: string, resultsType?: { singular: string, plural: string } }) {
const query = results.query === undefined
? (maxCount: number | undefined) => Promise.resolve(results)

Ładowanie…
Anuluj
Zapisz