Skip to content

Commit dd3dd56

Browse files
committed
Adds explain branch to commit graph
1 parent 7bbbefc commit dd3dd56

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

contributions.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,18 @@
13871387
]
13881388
}
13891389
},
1390+
"gitlens.graph.ai.explainBranch": {
1391+
"label": "Explain Branch (Preview)",
1392+
"menus": {
1393+
"webview/context": [
1394+
{
1395+
"when": "webviewItem =~ /gitlens:branch\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled",
1396+
"group": "1_gitlens_actions_4",
1397+
"order": 100
1398+
}
1399+
]
1400+
}
1401+
},
13901402
"gitlens.graph.ai.explainCommit": {
13911403
"label": "Explain Commit",
13921404
"menus": {

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6629,6 +6629,10 @@
66296629
"title": "Add as Co-author",
66306630
"icon": "$(person-add)"
66316631
},
6632+
{
6633+
"command": "gitlens.graph.ai.explainBranch",
6634+
"title": "Explain Branch (Preview)"
6635+
},
66326636
{
66336637
"command": "gitlens.graph.ai.explainCommit",
66346638
"title": "Explain Commit"
@@ -10830,6 +10834,10 @@
1083010834
"command": "gitlens.graph.addAuthor",
1083110835
"when": "false"
1083210836
},
10837+
{
10838+
"command": "gitlens.graph.ai.explainBranch",
10839+
"when": "false"
10840+
},
1083310841
{
1083410842
"command": "gitlens.graph.ai.explainCommit",
1083510843
"when": "false"
@@ -20074,6 +20082,11 @@
2007420082
"when": "webviewItem =~ /gitlens:(branch|tag)\\b/ && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled",
2007520083
"group": "1_gitlens_actions_3@100"
2007620084
},
20085+
{
20086+
"command": "gitlens.graph.ai.explainBranch",
20087+
"when": "webviewItem =~ /gitlens:branch\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled && config.gitlens.ai.enabled",
20088+
"group": "1_gitlens_actions_4@100"
20089+
},
2007720090
{
2007820091
"command": "gitlens.graph.openBranchOnRemote",
2007920092
"when": "webviewItem =~ /gitlens:branch\\b(?=.*?\\b\\+(tracking|remote)\\b)/ && gitlens:repos:withRemotes",

src/constants.commands.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type ContributedCommands =
2323
| 'gitlens.copyRemoteRepositoryUrl'
2424
| 'gitlens.ghpr.views.openOrCreateWorktree'
2525
| 'gitlens.graph.addAuthor'
26+
| 'gitlens.graph.ai.explainBranch'
2627
| 'gitlens.graph.ai.explainCommit'
2728
| 'gitlens.graph.ai.explainStash'
2829
| 'gitlens.graph.ai.explainWip'

src/webviews/plus/graph/graphWebview.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
685685
this.copyWorkingChangesToWorktree,
686686
),
687687
this.host.registerWebviewCommand('gitlens.graph.ai.generateCommitMessage', this.generateCommitMessage),
688+
this.host.registerWebviewCommand('gitlens.graph.ai.explainBranch', this.explainBranch),
688689
this.host.registerWebviewCommand('gitlens.graph.ai.explainCommit', this.explainCommit),
689690
this.host.registerWebviewCommand('gitlens.graph.ai.explainStash', this.explainStash),
690691
this.host.registerWebviewCommand('gitlens.graph.ai.explainWip', this.explainWip),
@@ -3885,6 +3886,17 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
38853886
});
38863887
}
38873888

3889+
@log()
3890+
private explainBranch(item?: GraphItemContext) {
3891+
const ref = this.getGraphItemRef(item, 'branch');
3892+
if (ref == null) return Promise.resolve();
3893+
3894+
return executeCommand('gitlens.ai.explainBranch', {
3895+
repoPath: ref.repoPath,
3896+
ref: ref.ref,
3897+
source: { source: 'graph', type: 'branch' },
3898+
});
3899+
}
38883900
@log()
38893901
private explainCommit(item?: GraphItemContext) {
38903902
const ref = this.getGraphItemRef(item, 'revision');

0 commit comments

Comments
 (0)