Skip to content

Commit 1cc71dd

Browse files
eamodiosaeedzaha
authored andcommitted
Prefixes AI commands with ai.
Splits deprecated commands from the rest Honors org AI setting for stash/changelog
1 parent 742a820 commit 1cc71dd

23 files changed

+158
-176
lines changed

contributions.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
]
2424
}
2525
},
26+
"gitlens.ai.generateCommitMessage": {
27+
"label": "Generate Commit Message...",
28+
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:gk:organization:ai:enabled && config.gitlens.ai.generateCommitMessage.enabled"
29+
},
2630
"gitlens.annotations.nextChange": {
2731
"label": "Next Change",
2832
"icon": "$(arrow-down)"
@@ -1267,10 +1271,6 @@
12671271
]
12681272
}
12691273
},
1270-
"gitlens.generateCommitMessage": {
1271-
"label": "Generate Commit Message...",
1272-
"commandPalette": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:gk:organization:ai:enabled && config.gitlens.ai.generateCommitMessage.enabled"
1273-
},
12741274
"gitlens.getStarted": {
12751275
"label": "Get Started",
12761276
"commandPalette": true,
@@ -1457,6 +1457,18 @@
14571457
]
14581458
}
14591459
},
1460+
"gitlens.graph.ai.generateCommitMessage": {
1461+
"label": "Generate Commit Message...",
1462+
"menus": {
1463+
"webview/context": [
1464+
{
1465+
"when": "webviewItem == gitlens:wip && config.gitlens.ai.generateCommitMessage.enabled && !listMultiSelection && gitlens:gk:organization:ai:enabled && !gitlens:hasVirtualFolders && !gitlens:readonly && !gitlens:untrusted",
1466+
"group": "1_gitlens",
1467+
"order": 2
1468+
}
1469+
]
1470+
}
1471+
},
14601472
"gitlens.graph.associateIssueWithBranch": {
14611473
"label": "Associate Issue with Branch...",
14621474
"enablement": "!operationInProgress",
@@ -2078,18 +2090,6 @@
20782090
]
20792091
}
20802092
},
2081-
"gitlens.graph.generateCommitMessage": {
2082-
"label": "Generate Commit Message...",
2083-
"menus": {
2084-
"webview/context": [
2085-
{
2086-
"when": "webviewItem == gitlens:wip && config.gitlens.ai.generateCommitMessage.enabled && !listMultiSelection && gitlens:gk:organization:ai:enabled && !gitlens:hasVirtualFolders && !gitlens:readonly && !gitlens:untrusted",
2087-
"group": "1_gitlens",
2088-
"order": 2
2089-
}
2090-
]
2091-
}
2092-
},
20932093
"gitlens.graph.hideLocalBranch": {
20942094
"label": "Hide Local Branch",
20952095
"menus": {
@@ -3581,7 +3581,7 @@
35813581
]
35823582
}
35833583
},
3584-
"gitlens.scm.generateCommitMessage": {
3584+
"gitlens.scm.ai.generateCommitMessage": {
35853585
"label": "Generate Commit Message with GitLens...",
35863586
"menus": {
35873587
"git.commit": [
@@ -4905,6 +4905,24 @@
49054905
]
49064906
}
49074907
},
4908+
"gitlens.views.ai.generateChangelog": {
4909+
"label": "Generate Changelog",
4910+
"icon": "$(sparkle)",
4911+
"menus": {
4912+
"view/item/context": [
4913+
{
4914+
"when": "viewItem =~ /gitlens:compare:results:commits\\b/ && gitlens:gk:organization:ai:enabled",
4915+
"group": "inline",
4916+
"order": 98
4917+
},
4918+
{
4919+
"when": "viewItem =~ /gitlens:compare:results:commits\\b/ && !listMultiSelection && gitlens:gk:organization:ai:enabled",
4920+
"group": "4_gitlens_actions",
4921+
"order": 2
4922+
}
4923+
]
4924+
}
4925+
},
49084926
"gitlens.views.applyChanges": {
49094927
"label": "Apply Changes",
49104928
"enablement": "!operationInProgress",
@@ -7175,24 +7193,6 @@
71757193
]
71767194
}
71777195
},
7178-
"gitlens.views.generateChangelog": {
7179-
"label": "Generate Changelog",
7180-
"icon": "$(sparkle)",
7181-
"menus": {
7182-
"view/item/context": [
7183-
{
7184-
"when": "viewItem =~ /gitlens:compare:results:commits\\b/",
7185-
"group": "inline",
7186-
"order": 98
7187-
},
7188-
{
7189-
"when": "viewItem =~ /gitlens:compare:results:commits\\b/ && !listMultiSelection",
7190-
"group": "4_gitlens_actions",
7191-
"order": 2
7192-
}
7193-
]
7194-
}
7195-
},
71967196
"gitlens.views.graph.openInTab": {
71977197
"label": "Open in Editor",
71987198
"icon": "$(link-external)",

package.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5986,6 +5986,11 @@
59865986
"category": "GitLens",
59875987
"icon": "$(person-add)"
59885988
},
5989+
{
5990+
"command": "gitlens.ai.generateCommitMessage",
5991+
"title": "Generate Commit Message...",
5992+
"category": "GitLens"
5993+
},
59895994
{
59905995
"command": "gitlens.annotations.nextChange",
59915996
"title": "Next Change",
@@ -6357,11 +6362,6 @@
63576362
"icon": "$(repo-fetch)",
63586363
"enablement": "!operationInProgress"
63596364
},
6360-
{
6361-
"command": "gitlens.generateCommitMessage",
6362-
"title": "Generate Commit Message...",
6363-
"category": "GitLens"
6364-
},
63656365
{
63666366
"command": "gitlens.getStarted",
63676367
"title": "Get Started",
@@ -6547,6 +6547,10 @@
65476547
"title": "Add as Co-author",
65486548
"icon": "$(person-add)"
65496549
},
6550+
{
6551+
"command": "gitlens.graph.ai.generateCommitMessage",
6552+
"title": "Generate Commit Message..."
6553+
},
65506554
{
65516555
"command": "gitlens.graph.associateIssueWithBranch",
65526556
"title": "Associate Issue with Branch...",
@@ -6772,10 +6776,6 @@
67726776
"icon": "$(repo-fetch)",
67736777
"enablement": "!operationInProgress"
67746778
},
6775-
{
6776-
"command": "gitlens.graph.generateCommitMessage",
6777-
"title": "Generate Commit Message..."
6778-
},
67796779
{
67806780
"command": "gitlens.graph.hideLocalBranch",
67816781
"title": "Hide Local Branch"
@@ -7354,7 +7354,7 @@
73547354
"category": "GitLens"
73557355
},
73567356
{
7357-
"command": "gitlens.scm.generateCommitMessage",
7357+
"command": "gitlens.scm.ai.generateCommitMessage",
73587358
"title": "Generate Commit Message with GitLens..."
73597359
},
73607360
{
@@ -7831,6 +7831,11 @@
78317831
"icon": "$(add)",
78327832
"enablement": "!operationInProgress"
78337833
},
7834+
{
7835+
"command": "gitlens.views.ai.generateChangelog",
7836+
"title": "Generate Changelog",
7837+
"icon": "$(sparkle)"
7838+
},
78347839
{
78357840
"command": "gitlens.views.applyChanges",
78367841
"title": "Apply Changes",
@@ -8386,11 +8391,6 @@
83868391
"command": "gitlens.views.fileHistory.setShowMergeCommitsOn",
83878392
"title": "Show Merge Commits"
83888393
},
8389-
{
8390-
"command": "gitlens.views.generateChangelog",
8391-
"title": "Generate Changelog",
8392-
"icon": "$(sparkle)"
8393-
},
83948394
{
83958395
"command": "gitlens.views.graph.openInTab",
83968396
"title": "Open in Editor",
@@ -10298,6 +10298,10 @@
1029810298
"command": "gitlens.addAuthors",
1029910299
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
1030010300
},
10301+
{
10302+
"command": "gitlens.ai.generateCommitMessage",
10303+
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:gk:organization:ai:enabled && config.gitlens.ai.generateCommitMessage.enabled"
10304+
},
1030110305
{
1030210306
"command": "gitlens.annotations.nextChange",
1030310307
"when": "false"
@@ -10566,10 +10570,6 @@
1056610570
"command": "gitlens.fetchRepositories",
1056710571
"when": "gitlens:repos:withRemotes && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
1056810572
},
10569-
{
10570-
"command": "gitlens.generateCommitMessage",
10571-
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:gk:organization:ai:enabled && config.gitlens.ai.generateCommitMessage.enabled"
10572-
},
1057310573
{
1057410574
"command": "gitlens.ghpr.views.openOrCreateWorktree",
1057510575
"when": "false"
@@ -10714,6 +10714,10 @@
1071410714
"command": "gitlens.graph.addAuthor",
1071510715
"when": "false"
1071610716
},
10717+
{
10718+
"command": "gitlens.graph.ai.generateCommitMessage",
10719+
"when": "false"
10720+
},
1071710721
{
1071810722
"command": "gitlens.graph.associateIssueWithBranch",
1071910723
"when": "false"
@@ -10902,10 +10906,6 @@
1090210906
"command": "gitlens.graph.fetch",
1090310907
"when": "false"
1090410908
},
10905-
{
10906-
"command": "gitlens.graph.generateCommitMessage",
10907-
"when": "false"
10908-
},
1090910909
{
1091010910
"command": "gitlens.graph.hideLocalBranch",
1091110911
"when": "false"
@@ -11343,7 +11343,7 @@
1134311343
"when": "resource in gitlens:tabs:blameable"
1134411344
},
1134511345
{
11346-
"command": "gitlens.scm.generateCommitMessage",
11346+
"command": "gitlens.scm.ai.generateCommitMessage",
1134711347
"when": "false"
1134811348
},
1134911349
{
@@ -11686,6 +11686,10 @@
1168611686
"command": "gitlens.views.addRemote",
1168711687
"when": "false"
1168811688
},
11689+
{
11690+
"command": "gitlens.views.ai.generateChangelog",
11691+
"when": "false"
11692+
},
1168911693
{
1169011694
"command": "gitlens.views.applyChanges",
1169111695
"when": "false"
@@ -12162,10 +12166,6 @@
1216212166
"command": "gitlens.views.fileHistory.setShowMergeCommitsOn",
1216312167
"when": "false"
1216412168
},
12165-
{
12166-
"command": "gitlens.views.generateChangelog",
12167-
"when": "false"
12168-
},
1216912169
{
1217012170
"command": "gitlens.views.graph.openInTab",
1217112171
"when": "false"
@@ -13758,7 +13758,7 @@
1375813758
"group": "4_gitlens@3"
1375913759
},
1376013760
{
13761-
"command": "gitlens.scm.generateCommitMessage",
13761+
"command": "gitlens.scm.ai.generateCommitMessage",
1376213762
"when": "gitlens:enabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && gitlens:gk:organization:ai:enabled && config.gitlens.ai.generateCommitMessage.enabled && config.gitlens.menus.scmRepository.generateCommitMessage",
1376313763
"group": "4_gitlens@4"
1376413764
}
@@ -15939,7 +15939,7 @@
1593915939
"group": "2_z_gitlens@3"
1594015940
},
1594115941
{
15942-
"command": "gitlens.scm.generateCommitMessage",
15942+
"command": "gitlens.scm.ai.generateCommitMessage",
1594315943
"when": "scmProvider == git && gitlens:enabled && config.gitlens.ai.generateCommitMessage.enabled && config.gitlens.menus.scmRepository.generateCommitMessage && gitlens:gk:organization:ai:enabled && !gitlens:hasVirtualFolders && !gitlens:readonly && !gitlens:untrusted",
1594415944
"group": "2_z_gitlens@4"
1594515945
},
@@ -16650,8 +16650,8 @@
1665016650
"group": "2_gitlens_quickopen@2"
1665116651
},
1665216652
{
16653-
"command": "gitlens.views.generateChangelog",
16654-
"when": "viewItem =~ /gitlens:compare:results:commits\\b/",
16653+
"command": "gitlens.views.ai.generateChangelog",
16654+
"when": "viewItem =~ /gitlens:compare:results:commits\\b/ && gitlens:gk:organization:ai:enabled",
1665516655
"group": "inline@98"
1665616656
},
1665716657
{
@@ -16666,8 +16666,8 @@
1666616666
"group": "3_gitlens_explore@0"
1666716667
},
1666816668
{
16669-
"command": "gitlens.views.generateChangelog",
16670-
"when": "viewItem =~ /gitlens:compare:results:commits\\b/ && !listMultiSelection",
16669+
"command": "gitlens.views.ai.generateChangelog",
16670+
"when": "viewItem =~ /gitlens:compare:results:commits\\b/ && !listMultiSelection && gitlens:gk:organization:ai:enabled",
1667116671
"group": "4_gitlens_actions@2"
1667216672
},
1667316673
{
@@ -20140,7 +20140,7 @@
2014020140
"group": "1_gitlens@1"
2014120141
},
2014220142
{
20143-
"command": "gitlens.graph.generateCommitMessage",
20143+
"command": "gitlens.graph.ai.generateCommitMessage",
2014420144
"when": "webviewItem == gitlens:wip && config.gitlens.ai.generateCommitMessage.enabled && !listMultiSelection && gitlens:gk:organization:ai:enabled && !gitlens:hasVirtualFolders && !gitlens:readonly && !gitlens:untrusted",
2014520145
"group": "1_gitlens@2"
2014620146
},

src/commands/commandBase.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { TextEditor, TextEditorEdit } from 'vscode';
22
import { commands, Disposable } from 'vscode';
3-
import type { GlCommands } from '../constants.commands';
3+
import type { GlCommands, GlCommandsDeprecated } from '../constants.commands';
44
import { registerCommand } from '../system/-webview/command';
55
import type { CommandContext } from './commandContext';
66
import type { CommandContextParsingOptions } from './commandContext.utils';
@@ -11,14 +11,10 @@ export abstract class GlCommandBase implements Disposable {
1111

1212
private readonly _disposable: Disposable;
1313

14-
constructor(command: GlCommands | GlCommands[]) {
15-
if (typeof command === 'string') {
16-
this._disposable = registerCommand(command, (...args: any[]) => this._execute(command, ...args), this);
17-
18-
return;
19-
}
14+
constructor(command: GlCommands | GlCommands[], deprecated?: GlCommandsDeprecated[]) {
15+
const commands = [...(typeof command === 'string' ? [command] : command), ...(deprecated ?? [])];
2016

21-
const subscriptions = command.map(cmd =>
17+
const subscriptions = commands.map(cmd =>
2218
registerCommand(cmd, (...args: any[]) => this._execute(cmd, ...args), this),
2319
);
2420
this._disposable = Disposable.from(...subscriptions);
@@ -35,7 +31,7 @@ export abstract class GlCommandBase implements Disposable {
3531

3632
abstract execute(...args: any[]): any;
3733

38-
protected _execute(command: GlCommands, ...args: any[]): Promise<unknown> {
34+
protected _execute(command: GlCommands | GlCommandsDeprecated, ...args: any[]): Promise<unknown> {
3935
const [context, rest] = parseCommandContext(command, { ...this.contextParsingOptions }, ...args);
4036
return this.preExecute(context, ...rest);
4137
}

src/commands/commandContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
TextEditor,
77
Uri,
88
} from 'vscode';
9-
import type { GlCommands } from '../constants.commands';
9+
import type { GlCommands, GlCommandsDeprecated } from '../constants.commands';
1010
import type { ViewNode } from '../views/nodes/abstract/viewNode';
1111

1212
export type CommandContext =
@@ -23,7 +23,7 @@ export type CommandContext =
2323
| CommandViewNodesContext;
2424

2525
export interface CommandContextBase {
26-
command: GlCommands;
26+
command: GlCommands | GlCommandsDeprecated;
2727
editor?: TextEditor;
2828
uri?: Uri;
2929

src/commands/commandContext.utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { GitTimelineItem, SourceControl, TextEditor } from 'vscode';
22
import { Uri, window } from 'vscode';
3-
import type { GlCommands } from '../constants.commands';
3+
import type { GlCommands, GlCommandsDeprecated } from '../constants.commands';
44
import type { StoredNamedRef } from '../constants.storage';
55
import type { GitBranch } from '../git/models/branch';
66
import { isBranch } from '../git/models/branch';
@@ -158,7 +158,7 @@ export interface CommandContextParsingOptions {
158158
}
159159

160160
export function parseCommandContext(
161-
command: GlCommands,
161+
command: GlCommands | GlCommandsDeprecated,
162162
options?: CommandContextParsingOptions,
163163
...args: any[]
164164
): [CommandContext, any[]] {

0 commit comments

Comments
 (0)