Skip to content

Commit 09d6ee8

Browse files
committed
Adds explain commit to commit graph
1 parent aa92424 commit 09d6ee8

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

contributions.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,6 +1984,18 @@
19841984
]
19851985
}
19861986
},
1987+
"gitlens.graph.explainCommit": {
1988+
"label": "Explain Commit",
1989+
"menus": {
1990+
"webview/context": [
1991+
{
1992+
"when": "webviewItem =~ /gitlens:commit\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
1993+
"group": "1_gitlens_actions_3",
1994+
"order": 1
1995+
}
1996+
]
1997+
}
1998+
},
19871999
"gitlens.graph.fetch": {
19882000
"label": "Fetch",
19892001
"icon": "$(repo-fetch)",

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6808,6 +6808,10 @@
68086808
"icon": "$(trash)",
68096809
"enablement": "!operationInProgress"
68106810
},
6811+
{
6812+
"command": "gitlens.graph.explainCommit",
6813+
"title": "Explain Commit"
6814+
},
68116815
{
68126816
"command": "gitlens.graph.fetch",
68136817
"title": "Fetch",
@@ -10949,6 +10953,10 @@
1094910953
"command": "gitlens.graph.deleteTag",
1095010954
"when": "false"
1095110955
},
10956+
{
10957+
"command": "gitlens.graph.explainCommit",
10958+
"when": "false"
10959+
},
1095210960
{
1095310961
"command": "gitlens.graph.fetch",
1095410962
"when": "false"
@@ -20104,6 +20112,11 @@
2010420112
"when": "webviewItem =~ /gitlens:commit\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
2010520113
"group": "1_gitlens_actions_1@4"
2010620114
},
20115+
{
20116+
"command": "gitlens.graph.explainCommit",
20117+
"when": "webviewItem =~ /gitlens:commit\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
20118+
"group": "1_gitlens_actions_3@1"
20119+
},
2010720120
{
2010820121
"submenu": "gitlens/graph/commit/changes",
2010920122
"when": "webviewItem =~ /gitlens:(commit|stash|wip)\\b/ && !listMultiSelection",

src/webviews/plus/graph/graphWebview.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
686686
this.copyWorkingChangesToWorktree,
687687
),
688688
this.host.registerWebviewCommand('gitlens.graph.ai.generateCommitMessage', this.generateCommitMessage),
689+
this.host.registerWebviewCommand('gitlens.graph.explainCommit', this.explainCommit),
689690

690691
this.host.registerWebviewCommand('gitlens.graph.compareSelectedCommits.multi', this.compareSelectedCommits),
691692
this.host.registerWebviewCommand('gitlens.graph.abortPausedOperation', this.abortPausedOperation),
@@ -3802,6 +3803,18 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
38023803
});
38033804
}
38043805

3806+
@log()
3807+
private explainCommit(item?: GraphItemContext) {
3808+
const ref = this.getGraphItemRef(item, 'revision');
3809+
if (ref == null) return Promise.resolve();
3810+
3811+
return executeCommand('gitlens.ai.explainCommit', {
3812+
repoPath: ref.repoPath,
3813+
ref: ref.ref,
3814+
source: { source: 'graph', type: 'commit' },
3815+
});
3816+
}
3817+
38053818
@log()
38063819
private async openFiles(item?: GraphItemContext) {
38073820
const commit = await this.getCommitFromGraphItemRef(item);

0 commit comments

Comments
 (0)