Quellcode durchsuchen

Fixes #1161, #1157 - re-adds file comparison

main
Eric Amodio vor 4 Jahren
Ursprung
Commit
2c3fad5d99
4 geänderte Dateien mit 78 neuen und 8 gelöschten Zeilen
  1. +7
    -0
      CHANGELOG.md
  2. +9
    -6
      README.md
  3. +31
    -1
      src/views/nodes/compareBranchNode.ts
  4. +31
    -1
      src/views/nodes/compareResultsNode.ts

+ 7
- 0
CHANGELOG.md Datei anzeigen

@ -4,6 +4,13 @@ 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]
### Fixed
- Fixes [#1161](https://github.com/eamodio/vscode-gitlens/issues/1161) - Compare file differences between branches
- Fixes [#1157](https://github.com/eamodio/vscode-gitlens/issues/1157) - GitLens report `X files changed` when comparing working tree with a branch having identical files
## [11.0.3] - 2020-11-22
### Fixed

+ 9
- 6
README.md Datei anzeigen

@ -252,9 +252,10 @@ The _Commits_ view lists all of the commits on the current branch, and additiona
- a toggle to change the file layout: list, tree, auto
- a branch comparison tool (**Compare <current branch> with <branch, tag, or ref>**) — [optionally](#commits-view-settings- 'Jump to the Commits view settings') shows a comparison of the current branch (or working tree) to a user-selected reference
- **Behind** — lists the commits that are missing from the current branch (i.e. behind) but exist in the selected reference
- **# files changed** — lists all of the files changed between the compared references
- **# files changed** — lists all of the files changed in the behind commits
- **Ahead** — lists the commits that the current branch has (i.e. ahead) but are missing in the selected reference
- **# files changed** — lists all of the files changed between the compared references
- **# files changed** — lists all of the files changed in the ahead commits
- **# files changed** — lists all of the files changed between the compared references
- the current branch status — shows the upstream status of the current branch
- **Publish <current branch> to <remote>** — shown when the current branch has not been published to a remote
- **Up to date with <remote>** — shown when the current branch is up to date with the upstream remote
@ -302,9 +303,10 @@ The _Branches_ view lists all of the local branches, and additionally provides,
- _Yellow dot_ — both unpublished and un-pulled changes
- a branch comparison tool (**Compare <branch> with <branch, tag, or ref>**) — [optionally](#branches-view-settings- 'Jump to the Branches view settings') shows a comparison of the branch to a user-selected reference
- **Behind** — lists the commits that are missing from the branch (i.e. behind) but exist in the selected reference
- **# files changed** — lists all of the files changed between the compared references
- **# files changed** — lists all of the files changed in the behind commits
- **Ahead** — lists the commits that the branch has (i.e. ahead) but are missing in the selected reference
- **# files changed** — lists all of the files changed between the compared references
- **# files changed** — lists all of the files changed in the ahead commits
- **# files changed** — lists all of the files changed between the compared references
- the branch status — shows the upstream status of the branch
- **Publish <branch> to <remote>** — shown when the current branch has not been published to a remote
- **Changes to push to <remote>** — lists of all the files changed in the unpublished commits when the branch has (unpublished) commits that waiting to be pushed to the upstream remote
@ -396,9 +398,10 @@ The _Search & Compare_ view lists pinnable (saved) results for searching commit
- _Show Commit_ command (`gitlens.showQuickCommitDetails`)
- pinnable comparison — shows a comparison of the two user-selected references
- **Behind** — lists the commits that are missing from the branch (i.e. behind) but exist in the selected reference
- **# files changed** — lists all of the files changed between the compared references
- **# files changed** — lists all of the files changed in the behind commits
- **Ahead** — lists the commits that the branch has (i.e. ahead) but are missing in the selected reference
- **# files changed** — lists all of the files changed between the compared references
- **# files changed** — lists all of the files changed in the ahead commits
- **# files changed** — lists all of the files changed between the compared references
- Comparision results can be provided by the following commands
- _Compare with Upstream_ command (`gitlens.views.compareWithUpstream`)
- _Compare with Working Tree_ command (`gitlens.views.compareWithWorking`)

+ 31
- 1
src/views/nodes/compareBranchNode.ts Datei anzeigen

@ -11,7 +11,7 @@ import { CommandQuickPickItem, ReferencePicker } from '../../quickpicks';
import { RepositoriesView } from '../repositoriesView';
import { RepositoryNode } from './repositoryNode';
import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode';
import { FilesQueryResults } from './resultsFilesNode';
import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode';
import { debug, gate, log, Strings } from '../../system';
import { ContextValues, ViewNode } from './viewNode';
@ -115,6 +115,18 @@ export class CompareBranchNode extends ViewNode
expand: false,
},
),
new ResultsFilesNode(
this.view,
this,
this.uri.repoPath!,
this.branch.ref,
this.compareWithWorkingTree ? '' : this._compareWith.ref || 'HEAD',
this.getFilesQuery.bind(this),
undefined,
{
expand: false,
},
),
];
}
return this._children;
@ -289,6 +301,24 @@ export class CompareBranchNode extends ViewNode
};
}
private async getFilesQuery(): Promise<FilesQueryResults> {
let comparison;
if (this._compareWith!.ref === '') {
comparison = this.branch.ref;
} else if (this.compareWithWorkingTree) {
comparison = this._compareWith!.ref;
} else {
comparison = `${this._compareWith!.ref}..${this.branch.ref}`;
}
const files = await Container.git.getDiffStatus(this.uri.repoPath!, comparison);
return {
label: `${Strings.pluralize('file', files?.length ?? 0, { zero: 'No' })} changed`,
files: files,
};
}
private loadCompareWith() {
const comparisons = Container.context.workspaceState.get<BranchComparisons>(WorkspaceState.BranchComparisons);

+ 31
- 1
src/views/nodes/compareResultsNode.ts Datei anzeigen

@ -6,7 +6,7 @@ import { GitRevision } from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { debug, gate, log, Strings } from '../../system';
import { CommitsQueryResults, ResultsCommitsNode } from './resultsCommitsNode';
import { FilesQueryResults } from './resultsFilesNode';
import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode';
import { ContextValues, ViewNode } from './viewNode';
import { RepositoryNode } from './repositoryNode';
import { SearchAndCompareView } from '../searchAndCompareView';
@ -121,6 +121,18 @@ export class CompareResultsNode extends ViewNode {
expand: false,
},
),
new ResultsFilesNode(
this.view,
this,
this.uri.repoPath!,
this._ref.ref,
this._compareWith.ref,
this.getFilesQuery.bind(this),
undefined,
{
expand: false,
},
),
];
}
return this._children;
@ -292,6 +304,24 @@ export class CompareResultsNode extends ViewNode {
};
}
private async getFilesQuery(): Promise<FilesQueryResults> {
let comparison;
if (this._compareWith.ref === '') {
comparison = this._ref.ref;
} else if (this._ref.ref === '') {
comparison = this._compareWith.ref;
} else {
comparison = `${this._compareWith.ref}..${this._ref.ref}`;
}
const files = await Container.git.getDiffStatus(this.uri.repoPath!, comparison);
return {
label: `${Strings.pluralize('file', files?.length ?? 0, { zero: 'No' })} changed`,
files: files,
};
}
private updatePinned() {
return this.view.updatePinned(this.getPinnableId(), {
type: 'comparison',

Laden…
Abbrechen
Speichern