Explorar el Código

Closes #279 - removes selected from ancestor compare

Adds custom label support to result view
main
Eric Amodio hace 6 años
padre
commit
266b43b012
Se han modificado 8 ficheros con 37 adiciones y 29 borrados
  1. +3
    -0
      CHANGELOG.md
  2. +2
    -2
      README.md
  3. +9
    -9
      package.json
  4. +2
    -2
      src/commands/diffDirectory.ts
  5. +7
    -7
      src/views/comparisonResultsNode.ts
  6. +6
    -6
      src/views/explorerCommands.ts
  7. +5
    -0
      src/views/explorerNode.ts
  8. +3
    -3
      src/views/resultsExplorer.ts

+ 3
- 0
CHANGELOG.md Ver fichero

@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Added
- Adds multi-cursor support to current line annotations — closes [#291](https://github.com/eamodio/vscode-gitlens/issues/291)
### Changed
- Renames *Compare Selected Ancestor with Working Tree* command to *Compare Ancestry with Working Tree* and removes the need to select a branch first, since all compares are done to the working tree — closes [#279](https://github.com/eamodio/vscode-gitlens/issues/279)
### Fixed
- Fixes [#294](https://github.com/eamodio/vscode-gitlens/issues/294) - Keyboard shortcuts will now default to *chorded* to avoid conflicts. FYI, only affects new installs or if you remove the `gitlens.keymap` setting)

+ 2
- 2
README.md Ver fichero

@ -107,7 +107,7 @@ The repository view provides a full Git repository explorer, which has the follo
- *Red* — behind the upstream
- *Yellow* — both ahead of and behind the upstream
- Context menus for each branch provide
- *Open Branch in Remote* (if available), *Compare with Remote* (if available), *Compare with Index (HEAD)*, *Compare with Working Tree*, *Compare with Selected* (when available), *Compare Selected Ancestor with Working Tree* (when available), *Select for Compare*, *Open Directory Compare with Working Tree*, *Checkout Branch (via Terminal)*, *Merge Branch (via Terminal)*, *Rebase (Interactive) Branch (via Terminal)*, *Rebase (Interactive) Branch to Remote (via Terminal)*, *Squash Branch into Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Delete Branch (via Terminal)*, *Create Tag (via Terminal)...*, and *Refresh* commands
- *Open Branch in Remote* (if available), *Compare with Remote* (if available), *Compare with Index (HEAD)*, *Compare with Working Tree*, *Compare with Selected* (when available), *Compare Ancestry with Working Tree* (when available), *Select for Compare*, *Open Directory Compare with Working Tree*, *Checkout Branch (via Terminal)*, *Merge Branch (via Terminal)*, *Rebase (Interactive) Branch (via Terminal)*, *Rebase (Interactive) Branch to Remote (via Terminal)*, *Squash Branch into Commit (via Terminal)*, *Create Branch (via Terminal)...*, *Delete Branch (via Terminal)*, *Create Tag (via Terminal)...*, and *Refresh* commands
- Revisions (commits) expand to show the set of files changed, complete with status indicators for adds, changes, renames, and deletes
- Context menus for each revision (commit) provide
- *Open Commit in Remote* (if available), *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 Index (HEAD)*, *Compare with Working Tree*, *Compare with Selected* (when available), *Select for Compare*, *Cherry Pick Commit (via Terminal)* (when available), *Push to Commit (via Terminal)* (when available), *Revert Commit (via Terminal)* (when available), *Rebase to Commit (via Terminal)* (when available), *Reset to Commit (via Terminal)* (when available), *Create Branch (via Terminal)...*, *Create Tag (via Terminal)...*, and *Refresh* commands
@ -183,7 +183,7 @@ An on-demand, [customizable](#gitlens-results-view-settings "Jump to the GitLens
- *Compare with Index (HEAD)* command (`gitlens.explorers.compareWithHead`)
- *Compare with Working Tree* command (`gitlens.explorers.compareWithWorking`)
- *Compare with Selected* command (`gitlens.explorers.compareWithSelected`)
- *Compare Selected Ancestor with Working Tree* command (`gitlens.explorers.compareSelectedAncestorWithWorking`)
- *Compare Ancestry with Working Tree* command (`gitlens.explorers.compareAncestryWithWorking`)
- An inline toolbar provides *Swap Comparision*, and *Clear Results* commands
- A context menu provides *Clear Results*, *Swap Comparision*, *Open Directory Compare*, and *Refresh* commands

+ 9
- 9
package.json Ver fichero

@ -1419,8 +1419,8 @@
"category": "GitLens"
},
{
"command": "gitlens.explorers.compareSelectedAncestorWithWorking",
"title": "Compare Selected Ancestor with Working Tree",
"command": "gitlens.explorers.compareAncestryWithWorking",
"title": "Compare Ancestry with Working Tree",
"category": "GitLens"
},
{
@ -1900,7 +1900,7 @@
"when": "false"
},
{
"command": "gitlens.explorers.compareSelectedAncestorWithWorking",
"command": "gitlens.explorers.compareAncestryWithWorking",
"when": "false"
},
{
@ -2410,19 +2410,19 @@
"group": "7_gitlens@3"
},
{
"command": "gitlens.explorers.compareAncestryWithWorking",
"when": "viewItem =~ /gitlens:branch\\b/",
"group": "7_gitlens@4"
},
{
"command": "gitlens.explorers.compareWithSelected",
"when": "viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/ && gitlens:explorers:canCompare",
"group": "7_gitlens_@1"
},
{
"command": "gitlens.explorers.compareSelectedAncestorWithWorking",
"when": "viewItem =~ /gitlens:branch\\b/ && gitlens:explorers:canCompare == branch",
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.selectForCompare",
"when": "viewItem =~ /gitlens:(branch|commit|stash|tag)\\b/",
"group": "7_gitlens_@3"
"group": "7_gitlens_@2"
},
{
"command": "gitlens.explorers.openDirectoryDiffWithWorking",

+ 2
- 2
src/commands/diffDirectory.ts Ver fichero

@ -29,8 +29,8 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
case Commands.ExplorersOpenDirectoryDiff:
if (context.type === 'view' && context.node instanceof ComparisonResultsNode) {
args.ref1 = context.node.ref1;
args.ref2 = context.node.ref2;
args.ref1 = context.node.ref1.ref;
args.ref2 = context.node.ref2.ref;
}
break;

+ 7
- 7
src/views/comparisonResultsNode.ts Ver fichero

@ -4,7 +4,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitsResultsNode } from './commitsResultsNode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { Explorer, ExplorerNode, ResourceType } from './explorerNode';
import { Explorer, ExplorerNode, NamedRef, ResourceType } from './explorerNode';
import { GitLog, GitService, GitStatusFile, GitUri } from '../gitService';
import { StatusFilesResultsNode } from './statusFilesResultsNode';
@ -12,8 +12,8 @@ export class ComparisonResultsNode extends ExplorerNode {
constructor(
public readonly repoPath: string,
public readonly ref1: string,
public readonly ref2: string,
public readonly ref1: NamedRef,
public readonly ref2: NamedRef,
private readonly explorer: Explorer
) {
super(GitUri.fromRepoPath(repoPath));
@ -22,7 +22,7 @@ export class ComparisonResultsNode extends ExplorerNode {
async getChildren(): Promise<ExplorerNode[]> {
this.resetChildren();
const commitsQueryFn = (maxCount: number | undefined) => Container.git.getLog(this.uri.repoPath!, { maxCount: maxCount, ref: `${this.ref1}...${this.ref2 || 'HEAD'}` });
const commitsQueryFn = (maxCount: number | undefined) => Container.git.getLog(this.uri.repoPath!, { maxCount: maxCount, ref: `${this.ref1.ref}...${this.ref2.ref || 'HEAD'}` });
const commitsLabelFn = async (log: GitLog | undefined) => {
const count = log !== undefined ? log.count : 0;
const truncated = log !== undefined ? log.truncated : false;
@ -31,7 +31,7 @@ export class ComparisonResultsNode extends ExplorerNode {
return `${count === 0 ? 'No' : `${count}${truncated ? '+' : ''}`} commits`;
};
const filesQueryFn = () => Container.git.getDiffStatus(this.uri.repoPath!, this.ref1, this.ref2);
const filesQueryFn = () => Container.git.getDiffStatus(this.uri.repoPath!, this.ref1.ref, this.ref2.ref);
const filesLabelFn = (diff: GitStatusFile[] | undefined) => {
const count = diff !== undefined ? diff.length : 0;
@ -41,7 +41,7 @@ export class ComparisonResultsNode extends ExplorerNode {
this.children = [
new CommitsResultsNode(this.uri.repoPath!, commitsLabelFn, commitsQueryFn, this.explorer),
new StatusFilesResultsNode(this.uri.repoPath!, this.ref1, this.ref2, filesLabelFn, filesQueryFn, this.explorer)
new StatusFilesResultsNode(this.uri.repoPath!, this.ref1.ref, this.ref2.ref, filesLabelFn, filesQueryFn, this.explorer)
];
return this.children;
@ -54,7 +54,7 @@ export class ComparisonResultsNode extends ExplorerNode {
repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`;
}
const item = new TreeItem(`Comparing ${GitService.shortenSha(this.ref1, { working: 'Working Tree' })} to ${GitService.shortenSha(this.ref2, { working: 'Working Tree' })}${repository}`, TreeItemCollapsibleState.Expanded);
const item = new TreeItem(`Comparing ${this.ref1.label || GitService.shortenSha(this.ref1.ref, { working: 'Working Tree' })} to ${this.ref2.label || GitService.shortenSha(this.ref2.ref, { working: 'Working Tree' })}${repository}`, TreeItemCollapsibleState.Expanded);
item.contextValue = ResourceType.ComparisonResults;
return item;
}

+ 6
- 6
src/views/explorerCommands.ts Ver fichero

@ -35,7 +35,7 @@ export class ExplorerCommands extends Disposable {
commands.registerCommand('gitlens.explorers.openChangedFileChangesWithWorking', this.openChangedFileChangesWithWorking, this);
commands.registerCommand('gitlens.explorers.openChangedFileRevisions', this.openChangedFileRevisions, this);
commands.registerCommand('gitlens.explorers.applyChanges', this.applyChanges, this);
commands.registerCommand('gitlens.explorers.compareSelectedAncestorWithWorking', this.compareSelectedAncestorWithWorking, this);
commands.registerCommand('gitlens.explorers.compareAncestryWithWorking', this.compareAncestryWithWorking, this);
commands.registerCommand('gitlens.explorers.compareWithHead', this.compareWithHead, this);
commands.registerCommand('gitlens.explorers.compareWithRemote', this.compareWithRemote, this);
commands.registerCommand('gitlens.explorers.compareWithSelected', this.compareWithSelected, this);
@ -85,14 +85,14 @@ export class ExplorerCommands extends Disposable {
Container.resultsExplorer.showComparisonInResults(node.repoPath, node.ref, '');
}
private async compareSelectedAncestorWithWorking(node: BranchNode) {
if (this._selection === undefined || !(node instanceof BranchNode)) return;
if (this._selection.repoPath !== node.repoPath || this._selection.type !== 'branch') return;
private async compareAncestryWithWorking(node: BranchNode) {
const branch = await Container.git.getBranch(node.repoPath);
if (branch === undefined) return;
const commonAncestor = await Container.git.getMergeBase(this._selection.repoPath, this._selection.ref, node.ref);
const commonAncestor = await Container.git.getMergeBase(node.repoPath, branch.name, node.ref);
if (commonAncestor === undefined) return;
Container.resultsExplorer.showComparisonInResults(this._selection.repoPath, commonAncestor, '');
Container.resultsExplorer.showComparisonInResults(node.repoPath, { ref: commonAncestor, label: `ancestry with ${node.ref} (${GitService.shortenSha(commonAncestor)})` }, '');
}
private compareWithSelected(node: ExplorerNode) {

+ 5
- 0
src/views/explorerNode.ts Ver fichero

@ -7,6 +7,11 @@ import { GitUri } from '../gitService';
import { GitExplorer } from './gitExplorer';
import { ResultsExplorer } from './resultsExplorer';
export interface NamedRef {
label?: string;
ref: string;
}
export enum RefreshReason {
ActiveEditorChanged = 'active-editor-changed',
AutoRefreshChanged = 'auto-refresh-changed',

+ 3
- 3
src/views/resultsExplorer.ts Ver fichero

@ -5,7 +5,7 @@ import { configuration, ExplorerFilesLayout, IExplorersConfig, IResultsExplorerC
import { CommandContext, GlyphChars, setCommandContext, WorkspaceState } from '../constants';
import { Container } from '../container';
import { RefreshNodeCommandArgs } from './explorerCommands';
import { CommitResultsNode, CommitsResultsNode, ComparisonResultsNode, ExplorerNode, MessageNode, RefreshReason, ResourceType } from './explorerNodes';
import { CommitResultsNode, CommitsResultsNode, ComparisonResultsNode, ExplorerNode, MessageNode, NamedRef, RefreshReason, ResourceType } from './explorerNodes';
import { GitLog, GitLogCommit } from '../gitService';
import { Logger } from '../logger';
import { Messages } from '../messages';
@ -132,8 +132,8 @@ export class ResultsExplorer extends Disposable implements TreeDataProvider
this._onDidChangeTreeData.fire();
}
showComparisonInResults(repoPath: string, ref1: string, ref2: string) {
this.addResults(new ComparisonResultsNode(repoPath, ref1, ref2, this));
showComparisonInResults(repoPath: string, ref1: string | NamedRef, ref2: string | NamedRef) {
this.addResults(new ComparisonResultsNode(repoPath, typeof ref1 === 'string' ? { ref: ref1 } : ref1, typeof ref2 === 'string' ? { ref: ref2 } : ref2, this));
this.showResults();
}

Cargando…
Cancelar
Guardar