Skip to content

Commit b7e6577

Browse files
committed
Adds 'Open All Changes with Common Base' command to branches
Changes "Common (Merge) Base" to "Common Base"
1 parent fd63ab7 commit b7e6577

File tree

4 files changed

+94
-9
lines changed

4 files changed

+94
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
99
### Added
1010

1111
- Adds support for Anthropic's Claude 3 Opus & Sonnet models for GitLens' experimental AI features
12-
- Adds a _Compare with Common (Merge) Base_ command to branches in the _Commit Graph_ and views to review the changes if the selected branch were to be merged by comparing the common ancestor (merge base) with the current branch to the selected branch
12+
- Adds a _Compare with Common Base_ command to branches in the _Commit Graph_ and views to review the changes if the selected branch were to be merged by comparing the common ancestor (merge base) with the current branch to the selected branch
13+
- Adds an _Open All Changes with Common Base_ command to branches in the _Commit Graph_ and views to review the changes if the selected branch were to be merged in the multi-diff editor
1314
- Adds a _Stash All Changes_ command to Source Control repository toolbar (off by default)
1415
- Adds the repository name as a prefix to worktree name when adding to the current workspace
1516
- Adds a better message when stashing only untracked files without including untracked files
@@ -18,7 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1819

1920
- Re-adds _Add to Workspace_ option when creating a worktree — closes [#3160](https://github.com/gitkraken/vscode-gitlens/issues/3160)
2021
- Changes _Commit Graph_ date style to default to the default date style — refs [#3153](https://github.com/gitkraken/vscode-gitlens/issues/3153)
21-
- Renames the _Compare Ancestry with Working Tree_ command on branches to _Compare Common (Merge) Base with Working Tree_ for better clarity
22+
- Renames the _Compare Ancestry with Working Tree_ command on branches to _Compare Common Base with Working Tree_ for better clarity
2223
- Improves _File Blame_ annotations performance and layout accuracy with certain character sets
2324
- Improves string formatting performance
2425

@@ -28,7 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2829
- Fixes [#3152](https://github.com/gitkraken/vscode-gitlens/issues/3152) - Fixes double encoding of redirect URLs during account sign-in which affects certain environments
2930
- Fixes [#3153](https://github.com/gitkraken/vscode-gitlens/issues/3153) - `gitlens.defaultDateStyle` not working in Commit Details view
3031
- Fixes the _Open Pull Request Changes_ & _Compare Pull Request_ commands to scope the changes only to the pull request
31-
- Fixes broken _Compare Common (Merge) Base with Working Tree_ (previously _Compare Ancestry with Working Tree_)
32+
- Fixes broken _Compare Common Base with Working Tree_ (previously _Compare Ancestry with Working Tree_)
3233
- Fixes issue when switching to a worktree via branch switch when there are multiple repos in the workspace
3334

3435
## [14.8.2] - 2024-02-16

package.json

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6747,12 +6747,18 @@
67476747
},
67486748
{
67496749
"command": "gitlens.views.compareAncestryWithWorking",
6750-
"title": "Compare Common (Merge) Base with Working Tree",
6750+
"title": "Compare Common Base with Working Tree",
67516751
"category": "GitLens"
67526752
},
67536753
{
67546754
"command": "gitlens.views.compareWithMergeBase",
6755-
"title": "Compare with Common (Merge) Base",
6755+
"title": "Compare with Common Base",
6756+
"category": "GitLens"
6757+
},
6758+
{
6759+
"command": "gitlens.views.openChangedFileDiffsWithMergeBase",
6760+
"title": "Open All Changes with Common Base",
6761+
"icon": "$(diff-multiple)",
67566762
"category": "GitLens"
67576763
},
67586764
{
@@ -8408,12 +8414,18 @@
84088414
},
84098415
{
84108416
"command": "gitlens.graph.compareAncestryWithWorking",
8411-
"title": "Compare Common (Merge) Base with Working Tree",
8417+
"title": "Compare Common Base with Working Tree",
84128418
"category": "GitLens"
84138419
},
84148420
{
84158421
"command": "gitlens.graph.compareWithMergeBase",
8416-
"title": "Compare with Common (Merge) Base",
8422+
"title": "Compare with Common Base",
8423+
"category": "GitLens"
8424+
},
8425+
{
8426+
"command": "gitlens.graph.openChangedFileDiffsWithMergeBase",
8427+
"title": "Open All Changes with Common Base",
8428+
"icon": "$(diff-multiple)",
84178429
"category": "GitLens"
84188430
},
84198431
{
@@ -10056,6 +10068,10 @@
1005610068
"command": "gitlens.views.compareWithMergeBase",
1005710069
"when": "false"
1005810070
},
10071+
{
10072+
"command": "gitlens.views.openChangedFileDiffsWithMergeBase",
10073+
"when": "false"
10074+
},
1005910075
{
1006010076
"command": "gitlens.views.compareWithHead",
1006110077
"when": "false"
@@ -11204,6 +11220,10 @@
1120411220
"command": "gitlens.graph.compareWithMergeBase",
1120511221
"when": "false"
1120611222
},
11223+
{
11224+
"command": "gitlens.graph.openChangedFileDiffsWithMergeBase",
11225+
"when": "false"
11226+
},
1120711227
{
1120811228
"command": "gitlens.graph.compareWithHead",
1120911229
"when": "false"
@@ -12963,10 +12983,15 @@
1296312983
"group": "2_gitlens_quickopen@1",
1296412984
"alt": "gitlens.copyRemoteBranchUrl"
1296512985
},
12986+
{
12987+
"command": "gitlens.views.openChangedFileDiffsWithMergeBase",
12988+
"when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/",
12989+
"group": "3_gitlens_explore@11"
12990+
},
1296612991
{
1296712992
"command": "gitlens.views.openDirectoryDiffWithWorking",
1296812993
"when": "!gitlens:hasVirtualFolders && viewItem =~ /gitlens:(branch|tag)\\b/",
12969-
"group": "3_gitlens_explore@11"
12994+
"group": "3_gitlens_explore@12"
1297012995
},
1297112996
{
1297212997
"command": "gitlens.views.compareWithUpstream",
@@ -14584,6 +14609,11 @@
1458414609
"when": "webviewItem =~ /gitlens:upstreamStatus\\b/",
1458514610
"group": "1_gitlens_actions@3"
1458614611
},
14612+
{
14613+
"command": "gitlens.graph.openChangedFileDiffsWithMergeBase",
14614+
"when": "!gitlens:hasVirtualFolders && webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/",
14615+
"group": "3_gitlens_explore@11"
14616+
},
1458714617
{
1458814618
"command": "gitlens.graph.compareWithUpstream",
1458914619
"when": "!gitlens:hasVirtualFolders && webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+tracking\\b)/",

src/plus/webviews/graph/graphWebview.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
463463
this.host.registerWebviewCommand('gitlens.graph.openPullRequestComparison', this.openPullRequestComparison),
464464
this.host.registerWebviewCommand('gitlens.graph.openPullRequestOnRemote', this.openPullRequestOnRemote),
465465

466+
this.host.registerWebviewCommand(
467+
'gitlens.graph.openChangedFileDiffsWithMergeBase',
468+
this.openChangedFileDiffsWithMergeBase,
469+
),
470+
466471
this.host.registerWebviewCommand('gitlens.graph.compareWithUpstream', this.compareWithUpstream),
467472
this.host.registerWebviewCommand('gitlens.graph.compareWithHead', this.compareHeadWith),
468473
this.host.registerWebviewCommand('gitlens.graph.compareWithWorking', this.compareWorkingWith),
@@ -2780,6 +2785,28 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
27802785
});
27812786
}
27822787

2788+
@debug()
2789+
private async openChangedFileDiffsWithMergeBase(item?: GraphItemContext) {
2790+
const ref = this.getGraphItemRef(item);
2791+
if (ref == null) return Promise.resolve();
2792+
2793+
const branch = await this.container.git.getBranch(ref.repoPath);
2794+
if (branch == null) return undefined;
2795+
2796+
const commonAncestor = await this.container.git.getMergeBase(ref.repoPath, branch.ref, ref.ref);
2797+
if (commonAncestor == null) return undefined;
2798+
2799+
return openComparisonChanges(
2800+
this.container,
2801+
{ repoPath: ref.repoPath, lhs: commonAncestor, rhs: ref.ref },
2802+
{
2803+
title: `Changes between ${branch.ref} (${shortenRevision(commonAncestor)}) ${
2804+
GlyphChars.ArrowLeftRightLong
2805+
} ${shortenRevision(ref.ref, { strings: { working: 'Working Tree' } })}`,
2806+
},
2807+
);
2808+
}
2809+
27832810
@debug()
27842811
private compareWithUpstream(item?: GraphItemContext) {
27852812
if (isGraphItemRefContext(item, 'branch')) {

src/views/viewCommands.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { DiffWithPreviousCommandArgs } from '../commands/diffWithPrevious';
66
import type { DiffWithWorkingCommandArgs } from '../commands/diffWithWorking';
77
import type { OpenFileAtRevisionCommandArgs } from '../commands/openFileAtRevision';
88
import type { ViewShowBranchComparison } from '../config';
9-
import { Commands } from '../constants';
9+
import { Commands, GlyphChars } from '../constants';
1010
import type { Container } from '../container';
1111
import { browseAtRevision } from '../git/actions';
1212
import * as BranchActions from '../git/actions/branch';
@@ -253,6 +253,12 @@ export class ViewCommands {
253253
registerViewCommand('gitlens.views.unstageDirectory', this.unstageDirectory, this);
254254
registerViewCommand('gitlens.views.unstageFile', this.unstageFile, this);
255255

256+
registerViewCommand(
257+
'gitlens.views.openChangedFileDiffsWithMergeBase',
258+
this.openChangedFileDiffsWithMergeBase,
259+
this,
260+
);
261+
256262
registerViewCommand('gitlens.views.compareAncestryWithWorking', this.compareAncestryWithWorking, this);
257263
registerViewCommand('gitlens.views.compareWithHead', this.compareHeadWith, this);
258264
registerViewCommand('gitlens.views.compareWithMergeBase', this.compareWithMergeBase, this);
@@ -947,6 +953,27 @@ export class ViewCommands {
947953
});
948954
}
949955

956+
@log()
957+
private async openChangedFileDiffsWithMergeBase(node: BranchNode) {
958+
if (!node.is('branch')) return Promise.resolve();
959+
960+
const branch = await this.container.git.getBranch(node.repoPath);
961+
if (branch == null) return undefined;
962+
963+
const commonAncestor = await this.container.git.getMergeBase(node.repoPath, branch.ref, node.ref.ref);
964+
if (commonAncestor == null) return undefined;
965+
966+
return CommitActions.openComparisonChanges(
967+
this.container,
968+
{ repoPath: node.repoPath, lhs: commonAncestor, rhs: node.ref.ref },
969+
{
970+
title: `Changes between ${branch.ref} (${shortenRevision(commonAncestor)}) ${
971+
GlyphChars.ArrowLeftRightLong
972+
} ${shortenRevision(node.ref.ref, { strings: { working: 'Working Tree' } })}`,
973+
},
974+
);
975+
}
976+
950977
@log()
951978
private compareWithUpstream(node: BranchNode) {
952979
if (!node.is('branch') || node.branch.upstream == null) return Promise.resolve();

0 commit comments

Comments
 (0)