Skip to content

Commit 0e42e58

Browse files
committed
Adds explain commit to commit graph
1 parent 8107e27 commit 0e42e58

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

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6795,6 +6795,10 @@
67956795
"icon": "$(trash)",
67966796
"enablement": "!operationInProgress"
67976797
},
6798+
{
6799+
"command": "gitlens.graph.explainCommit",
6800+
"title": "Explain Commit"
6801+
},
67986802
{
67996803
"command": "gitlens.graph.fetch",
68006804
"title": "Fetch",
@@ -10936,6 +10940,10 @@
1093610940
"command": "gitlens.graph.deleteTag",
1093710941
"when": "false"
1093810942
},
10943+
{
10944+
"command": "gitlens.graph.explainCommit",
10945+
"when": "false"
10946+
},
1093910947
{
1094010948
"command": "gitlens.graph.fetch",
1094110949
"when": "false"
@@ -20091,6 +20099,11 @@
2009120099
"when": "webviewItem =~ /gitlens:commit\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders",
2009220100
"group": "1_gitlens_actions_1@4"
2009320101
},
20102+
{
20103+
"command": "gitlens.graph.explainCommit",
20104+
"when": "webviewItem =~ /gitlens:commit\\b/ && !listMultiSelection && !gitlens:readonly && !gitlens:untrusted && gitlens:gk:organization:ai:enabled",
20105+
"group": "1_gitlens_actions_3@1"
20106+
},
2009420107
{
2009520108
"submenu": "gitlens/graph/commit/changes",
2009620109
"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)