diff --git a/CHANGELOG.md b/CHANGELOG.md index ec7ff95..4efb860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed +- Fixes [#2167](https://github.com/gitkraken/vscode-gitlens/issues/2167) - Rollup diff between working tree and fetched remote doesn't show changes - Fixes [#2166](https://github.com/gitkraken/vscode-gitlens/issues/2166) - Don't always prompt for GitHub authentication on virtual repositories - Fixes [#2156](https://github.com/gitkraken/vscode-gitlens/issues/2156) - Reduce extension package size - Fixes [#2136](https://github.com/gitkraken/vscode-gitlens/issues/2136) - Search & Compare quickpick shouldn't select the mode text when opening diff --git a/src/views/nodes/branchTrackingStatusFilesNode.ts b/src/views/nodes/branchTrackingStatusFilesNode.ts index 2e0dcd1..770db16 100644 --- a/src/views/nodes/branchTrackingStatusFilesNode.ts +++ b/src/views/nodes/branchTrackingStatusFilesNode.ts @@ -89,6 +89,7 @@ export class BranchTrackingStatusFilesNode extends ViewNode { this.repoPath, files[files.length - 1], files.map(s => s.commit), + this.direction, ), ); diff --git a/src/views/nodes/statusFileNode.ts b/src/views/nodes/statusFileNode.ts index c0e4690..020f7f0 100644 --- a/src/views/nodes/statusFileNode.ts +++ b/src/views/nodes/statusFileNode.ts @@ -19,10 +19,18 @@ export class StatusFileNode extends ViewNode implements FileNo public readonly file: GitFile; public readonly repoPath: string; + private readonly _direction: 'ahead' | 'behind'; private readonly _hasStagedChanges: boolean; private readonly _hasUnstagedChanges: boolean; - constructor(view: ViewsWithCommits, parent: ViewNode, repoPath: string, file: GitFile, commits: GitCommit[]) { + constructor( + view: ViewsWithCommits, + parent: ViewNode, + repoPath: string, + file: GitFile, + commits: GitCommit[], + direction: 'ahead' | 'behind' = 'ahead', + ) { let hasStagedChanges = false; let hasUnstagedChanges = false; let ref = undefined; @@ -53,6 +61,7 @@ export class StatusFileNode extends ViewNode implements FileNo this.file = file; this.commits = commits; + this._direction = direction; this._hasStagedChanges = hasStagedChanges; this._hasUnstagedChanges = hasUnstagedChanges; } @@ -244,11 +253,11 @@ export class StatusFileNode extends ViewNode implements FileNo }; } - const commit = this.commits[this.commits.length - 1]; + const commit = this._direction === 'behind' ? this.commits[0] : this.commits[this.commits.length - 1]; const file = commit.files?.find(f => f.path === this.file.path) ?? this.file; const commandArgs: DiffWithCommandArgs = { lhs: { - sha: `${commit.sha}^`, + sha: this._direction === 'behind' ? commit.sha : `${commit.sha}^`, uri: GitUri.fromFile(file, this.repoPath, undefined, true), }, rhs: {