Skip to content

Commit 30c6f9a

Browse files
committed
Prepares space for future AI-powered recompose actions for a branch
Introduces new AI-assisted commands to recompose all branch commits and specifically unpushed commits via the graph webview. (#4443)
1 parent 8095dc5 commit 30c6f9a

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

contributions.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,32 @@
2323
]
2424
}
2525
},
26+
"gitlens.ai.aiRebaseBranch:graph": {
27+
"label": "AI Recompose branch commits (Preview)...",
28+
"icon": "$(sparkle)",
29+
"menus": {
30+
"webview/context": [
31+
{
32+
"when": "webviewItem =~ /gitlens:branch\\b/ && !listMultiSelection",
33+
"group": "1_gitlens_actions",
34+
"order": 6
35+
}
36+
]
37+
}
38+
},
39+
"gitlens.ai.aiRebaseUnpushed:graph": {
40+
"label": "AI Recompose unpushed commits (Preview)...",
41+
"icon": "$(sparkle)",
42+
"menus": {
43+
"webview/context": [
44+
{
45+
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
46+
"group": "1_gitlens_actions",
47+
"order": 7
48+
}
49+
]
50+
}
51+
},
2652
"gitlens.ai.explainBranch": {
2753
"label": "Explain Branch Changes (Preview)...",
2854
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,6 +6189,16 @@
61896189
"category": "GitLens",
61906190
"icon": "$(person-add)"
61916191
},
6192+
{
6193+
"command": "gitlens.ai.aiRebaseBranch:graph",
6194+
"title": "AI Recompose branch commits (Preview)...",
6195+
"icon": "$(sparkle)"
6196+
},
6197+
{
6198+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
6199+
"title": "AI Recompose unpushed commits (Preview)...",
6200+
"icon": "$(sparkle)"
6201+
},
61926202
{
61936203
"command": "gitlens.ai.explainBranch",
61946204
"title": "Explain Branch Changes (Preview)...",
@@ -11014,6 +11024,14 @@
1101411024
"command": "gitlens.addAuthors",
1101511025
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
1101611026
},
11027+
{
11028+
"command": "gitlens.ai.aiRebaseBranch:graph",
11029+
"when": "false"
11030+
},
11031+
{
11032+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
11033+
"when": "false"
11034+
},
1101711035
{
1101811036
"command": "gitlens.ai.explainBranch",
1101911037
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled"
@@ -23287,6 +23305,16 @@
2328723305
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(remote|tracking)\\b)(?!.*?\\b\\+closed\\b)/ && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:repos:withRemotes",
2328823306
"group": "1_gitlens_actions@3"
2328923307
},
23308+
{
23309+
"command": "gitlens.ai.aiRebaseBranch:graph",
23310+
"when": "webviewItem =~ /gitlens:branch\\b/ && !listMultiSelection",
23311+
"group": "1_gitlens_actions@6"
23312+
},
23313+
{
23314+
"command": "gitlens.ai.aiRebaseUnpushed:graph",
23315+
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+ahead\\b)/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
23316+
"group": "1_gitlens_actions@7"
23317+
},
2329023318
{
2329123319
"command": "gitlens.graph.mergeBranchInto",
2329223320
"when": "webviewItem =~ /gitlens:branch\\b(?!.*?\\b\\+current\\b)/ && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",

src/constants.commands.generated.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
export type ContributedCommands =
55
| ContributedKeybindingCommands
66
| ContributedPaletteCommands
7+
| 'gitlens.ai.aiRebaseBranch:graph'
8+
| 'gitlens.ai.aiRebaseUnpushed:graph'
79
| 'gitlens.ai.explainBranch:graph'
810
| 'gitlens.ai.explainBranch:views'
911
| 'gitlens.ai.explainCommit:graph'

src/webviews/plus/graph/graphWebview.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
532532
this.host.registerWebviewCommand('gitlens.graph.associateIssueWithBranch', this.associateIssueWithBranch),
533533
this.host.registerWebviewCommand('gitlens.changeUpstream:graph', this.changeUpstreamBranch),
534534
this.host.registerWebviewCommand('gitlens.setUpstream:graph', this.changeUpstreamBranch),
535+
this.host.registerWebviewCommand('gitlens.ai.aiRebaseBranch:graph', this.aiRebaseBranch),
536+
this.host.registerWebviewCommand('gitlens.ai.aiRebaseUnpushed:graph', this.aiRebaseUnpushed),
535537

536538
this.host.registerWebviewCommand('gitlens.graph.switchToBranch', this.switchTo),
537539

@@ -3275,6 +3277,23 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
32753277
return Promise.resolve();
32763278
}
32773279

3280+
@log()
3281+
private aiRebaseBranch(item?: GraphItemContext) {
3282+
if (isGraphItemRefContext(item, 'branch')) {
3283+
}
3284+
3285+
return Promise.resolve();
3286+
}
3287+
3288+
@log()
3289+
private aiRebaseUnpushed(item?: GraphItemContext) {
3290+
if (isGraphItemRefContext(item, 'branch')) {
3291+
const { ref } = item.webviewItemValue;
3292+
}
3293+
3294+
return Promise.resolve();
3295+
}
3296+
32783297
@log()
32793298
private cherryPick(item?: GraphItemContext) {
32803299
const { selection } = this.getGraphItemRefs(item, 'revision');

0 commit comments

Comments
 (0)