Skip to content

Commit f3efa26

Browse files
d13sergeibbb
authored andcommitted
Adds explain commit to commit graph
1 parent 0e11ec0 commit f3efa26

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
@@ -1988,6 +1988,18 @@
19881988
]
19891989
}
19901990
},
1991+
"gitlens.graph.explainCommit": {
1992+
"label": "Explain Commit",
1993+
"menus": {
1994+
"webview/context": [
1995+
{
1996+
"when": "webviewItem =~ /gitlens:commit\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
1997+
"group": "1_gitlens_actions_3",
1998+
"order": 1
1999+
}
2000+
]
2001+
}
2002+
},
19912003
"gitlens.graph.fetch": {
19922004
"label": "Fetch",
19932005
"icon": "$(repo-fetch)",

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6827,6 +6827,10 @@
68276827
"icon": "$(trash)",
68286828
"enablement": "!operationInProgress"
68296829
},
6830+
{
6831+
"command": "gitlens.graph.explainCommit",
6832+
"title": "Explain Commit"
6833+
},
68306834
{
68316835
"command": "gitlens.graph.fetch",
68326836
"title": "Fetch",
@@ -10972,6 +10976,10 @@
1097210976
"command": "gitlens.graph.deleteTag",
1097310977
"when": "false"
1097410978
},
10979+
{
10980+
"command": "gitlens.graph.explainCommit",
10981+
"when": "false"
10982+
},
1097510983
{
1097610984
"command": "gitlens.graph.fetch",
1097710985
"when": "false"
@@ -20127,6 +20135,11 @@
2012720135
"when": "webviewItem =~ /gitlens:commit\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
2012820136
"group": "1_gitlens_actions_1@4"
2012920137
},
20138+
{
20139+
"command": "gitlens.graph.explainCommit",
20140+
"when": "webviewItem =~ /gitlens:commit\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
20141+
"group": "1_gitlens_actions_3@1"
20142+
},
2013020143
{
2013120144
"submenu": "gitlens/graph/commit/changes",
2013220145
"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)