Skip to content

Commit 28aee08

Browse files
committed
Closes #4498 adds set/unset upstream branch cmds
- Adds _[Set|Change] Upstream..._ context menus items for branches - Adds upstream sub-command to branch Git Command Palette
1 parent 7e859c8 commit 28aee08

File tree

13 files changed

+304
-28
lines changed

13 files changed

+304
-28
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1212
- Adds a new "Favorited Branches" option to the branches visibility dropdown on the _Commit Graph_
1313
- Adds _Add to Favorites_ or _Remove from Favorites_ context menu items to branches in the _Commit Graph_
1414
- Adds _Add to Favorites_ or _Remove from Favorites_ context menu items to worktrees in the views
15+
- Adds ability to set or change the upstream branch for branches in the _Commit Graph_ and other GitLens views ([#4498](https://github.com/gitkraken/vscode-gitlens/issues/4498))
16+
- Adds new _Set Upstream..._ and _Change Upstream..._ context menu items to branches in the _Commit Graph_ and other GitLens views
17+
- Adds a new _upstream_ sub-command to the _branch_ Git Command Palette
1518

1619
### Changed
1720

contributions.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,34 @@
407407
"label": "Change Branch Merge Target",
408408
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
409409
},
410+
"gitlens.changeUpstream:graph": {
411+
"label": "Change Upstream...",
412+
"icon": "$(link)",
413+
"enablement": "!operationInProgress",
414+
"menus": {
415+
"webview/context": [
416+
{
417+
"when": "webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+closed\\b)(?=.*?\\b\\+tracking\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
418+
"group": "1_gitlens_actions_2",
419+
"order": 3
420+
}
421+
]
422+
}
423+
},
424+
"gitlens.changeUpstream:views": {
425+
"label": "Change Upstream...",
426+
"icon": "$(link)",
427+
"enablement": "!operationInProgress",
428+
"menus": {
429+
"view/item/context": [
430+
{
431+
"when": "viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+closed\\b)(?=.*?\\b\\+tracking\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
432+
"group": "1_gitlens_actions_2",
433+
"order": 3
434+
}
435+
]
436+
}
437+
},
410438
"gitlens.clearFileAnnotations": {
411439
"label": "Clear File Annotations",
412440
"icon": "$(gitlens-gitlens-filled)",
@@ -3776,6 +3804,34 @@
37763804
]
37773805
}
37783806
},
3807+
"gitlens.setUpstream:graph": {
3808+
"label": "Set Upstream...",
3809+
"icon": "$(link)",
3810+
"enablement": "!operationInProgress",
3811+
"menus": {
3812+
"webview/context": [
3813+
{
3814+
"when": "webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+closed\\b)(?!.*?\\b\\+tracking\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
3815+
"group": "1_gitlens_actions_2",
3816+
"order": 3
3817+
}
3818+
]
3819+
}
3820+
},
3821+
"gitlens.setUpstream:views": {
3822+
"label": "Set Upstream...",
3823+
"icon": "$(link)",
3824+
"enablement": "!operationInProgress",
3825+
"menus": {
3826+
"view/item/context": [
3827+
{
3828+
"when": "viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+closed\\b)(?!.*?\\b\\+tracking\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
3829+
"group": "1_gitlens_actions_2",
3830+
"order": 3
3831+
}
3832+
]
3833+
}
3834+
},
37793835
"gitlens.shareAsCloudPatch": {
37803836
"label": "Share as Cloud Patch...",
37813837
"commandPalette": "gitlens:enabled && gitlens:gk:organization:drafts:enabled && config.gitlens.cloudPatches.enabled",

docs/telemetry-events.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6358,6 +6358,18 @@
63586358
"title": "Change Branch Merge Target",
63596359
"category": "GitLens"
63606360
},
6361+
{
6362+
"command": "gitlens.changeUpstream:graph",
6363+
"title": "Change Upstream...",
6364+
"icon": "$(link)",
6365+
"enablement": "!operationInProgress"
6366+
},
6367+
{
6368+
"command": "gitlens.changeUpstream:views",
6369+
"title": "Change Upstream...",
6370+
"icon": "$(link)",
6371+
"enablement": "!operationInProgress"
6372+
},
63616373
{
63626374
"command": "gitlens.clearFileAnnotations",
63636375
"title": "Clear File Annotations",
@@ -7595,6 +7607,18 @@
75957607
"title": "Reveal Commit in Side Bar",
75967608
"category": "GitLens"
75977609
},
7610+
{
7611+
"command": "gitlens.setUpstream:graph",
7612+
"title": "Set Upstream...",
7613+
"icon": "$(link)",
7614+
"enablement": "!operationInProgress"
7615+
},
7616+
{
7617+
"command": "gitlens.setUpstream:views",
7618+
"title": "Set Upstream...",
7619+
"icon": "$(link)",
7620+
"enablement": "!operationInProgress"
7621+
},
75987622
{
75997623
"command": "gitlens.shareAsCloudPatch",
76007624
"title": "Share as Cloud Patch...",
@@ -10899,6 +10923,14 @@
1089910923
"command": "gitlens.changeBranchMergeTarget",
1090010924
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
1090110925
},
10926+
{
10927+
"command": "gitlens.changeUpstream:graph",
10928+
"when": "false"
10929+
},
10930+
{
10931+
"command": "gitlens.changeUpstream:views",
10932+
"when": "false"
10933+
},
1090210934
{
1090310935
"command": "gitlens.clearFileAnnotations",
1090410936
"when": "resource in gitlens:tabs:blameable && (gitlens:window:annotated || resource in gitlens:tabs:annotated)"
@@ -11859,6 +11891,14 @@
1185911891
"command": "gitlens.revealCommitInView",
1186011892
"when": "resource in gitlens:tabs:blameable"
1186111893
},
11894+
{
11895+
"command": "gitlens.setUpstream:graph",
11896+
"when": "false"
11897+
},
11898+
{
11899+
"command": "gitlens.setUpstream:views",
11900+
"when": "false"
11901+
},
1186211902
{
1186311903
"command": "gitlens.shareAsCloudPatch",
1186411904
"when": "gitlens:enabled && gitlens:gk:organization:drafts:enabled && config.gitlens.cloudPatches.enabled"
@@ -16923,6 +16963,16 @@
1692316963
"when": "viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+closed\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
1692416964
"group": "1_gitlens_actions_2@2"
1692516965
},
16966+
{
16967+
"command": "gitlens.changeUpstream:views",
16968+
"when": "viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+closed\\b)(?=.*?\\b\\+tracking\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
16969+
"group": "1_gitlens_actions_2@3"
16970+
},
16971+
{
16972+
"command": "gitlens.setUpstream:views",
16973+
"when": "viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+closed\\b)(?!.*?\\b\\+tracking\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
16974+
"group": "1_gitlens_actions_2@3"
16975+
},
1692616976
{
1692716977
"command": "gitlens.views.deleteBranch",
1692816978
"when": "viewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)(?!.*?\\b\\+closed\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
@@ -22755,11 +22805,21 @@
2275522805
"when": "webviewItem =~ /gitlens:branch\\b/ && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
2275622806
"group": "1_gitlens_actions_2@2"
2275722807
},
22808+
{
22809+
"command": "gitlens.changeUpstream:graph",
22810+
"when": "webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+closed\\b)(?=.*?\\b\\+tracking\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
22811+
"group": "1_gitlens_actions_2@3"
22812+
},
2275822813
{
2275922814
"command": "gitlens.graph.deleteBranch",
2276022815
"when": "webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+(current|checkedout)\\b)/ && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
2276122816
"group": "1_gitlens_actions_2@3"
2276222817
},
22818+
{
22819+
"command": "gitlens.setUpstream:graph",
22820+
"when": "webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+remote\\b)(?!.*?\\b\\+closed\\b)(?!.*?\\b\\+tracking\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
22821+
"group": "1_gitlens_actions_2@3"
22822+
},
2276322823
{
2276422824
"command": "gitlens.graph.createBranch",
2276522825
"when": "webviewItem =~ /gitlens:branch\\b/ && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",

src/commands/changeBranchMergeTarget.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ThemeIcon } from 'vscode';
12
import type { Container } from '../container';
23
import type { GitBranch } from '../git/models/branch';
34
import type { Repository } from '../git/models/repository';
@@ -92,11 +93,14 @@ export class ChangeBranchMergeTargetCommand extends QuickCommand {
9293
picked: state.mergeBranch,
9394
placeholder: 'Pick a merge target branch',
9495
filter: (branch: GitBranch) => branch.remote && branch.name !== state.branch,
95-
reset: {
96-
allowed: userMergeTarget != null && detectedMergeTarget !== userMergeTarget,
97-
label: 'Reset Merge Target',
98-
detail: 'Reset the merge target branch to be automatically detected',
99-
},
96+
reset:
97+
userMergeTarget != null && detectedMergeTarget !== userMergeTarget
98+
? {
99+
label: 'Reset Merge Target',
100+
detail: 'Reset the merge target branch to be automatically detected',
101+
button: { icon: new ThemeIcon('discard'), tooltip: 'Reset Merge Target' },
102+
}
103+
: undefined,
100104
});
101105
if (result === StepResultBreak) continue;
102106

0 commit comments

Comments
 (0)