Skip to content

Commit 6c7a604

Browse files
committed
Improves command type generation script
- Groups commands by their contribution points - Tracks unused/orphaned commands Cleans up orphaned and internal commands Adds `gitlens.showQuickCommitDetails` to the command palette Adds keybinding support for launchpad copy action (ctrl+c / cmd+c)
1 parent 201d910 commit 6c7a604

File tree

7 files changed

+189
-145
lines changed

7 files changed

+189
-145
lines changed

contributions.json

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,6 @@
370370
]
371371
}
372372
},
373-
"gitlens.ai.undoGenerateRebase": {
374-
"label": "Undo AI Generated Changes (Preview)...",
375-
"icon": "$(discard)"
376-
},
377373
"gitlens.annotations.nextChange": {
378374
"label": "Next Change",
379375
"icon": "$(arrow-down)"
@@ -3348,9 +3344,6 @@
33483344
]
33493345
}
33503346
},
3351-
"gitlens.openCloudPatch": {
3352-
"label": "Open Cloud Patch..."
3353-
},
33543347
"gitlens.openCommitOnRemote": {
33553348
"label": "Open Commit on Remote",
33563349
"icon": "$(globe)",
@@ -4241,10 +4234,6 @@
42414234
]
42424235
}
42434236
},
4244-
"gitlens.showInCommitGraphView": {
4245-
"label": "Open in Commit Graph",
4246-
"icon": "$(gitlens-graph)"
4247-
},
42484237
"gitlens.showInDetailsView": {
42494238
"label": "Inspect Details",
42504239
"icon": "$(eye)",
@@ -4344,7 +4333,8 @@
43444333
"commandPalette": "gitlens:enabled"
43454334
},
43464335
"gitlens.showQuickCommitDetails": {
4347-
"label": "Quick Show Commit"
4336+
"label": "Quick Show Commit",
4337+
"commandPalette": "resource in gitlens:tabs:blameable"
43484338
},
43494339
"gitlens.showQuickCommitFileDetails": {
43504340
"label": "Quick Show Line Commit",
@@ -4947,10 +4937,6 @@
49474937
]
49484938
}
49494939
},
4950-
"gitlens.showSettingsPage!views": {
4951-
"label": "Open Settings",
4952-
"icon": "$(gear)"
4953-
},
49544940
"gitlens.showSettingsPage!worktrees-view": {
49554941
"label": "Open View Settings",
49564942
"icon": "$(gear)",
@@ -5585,10 +5571,6 @@
55855571
]
55865572
}
55875573
},
5588-
"gitlens.toggleFileChangesOnly": {
5589-
"label": "Toggle File Changes",
5590-
"icon": "$(gitlens-gitlens)"
5591-
},
55925574
"gitlens.toggleFileHeatmap": {
55935575
"label": "Toggle File Heatmap",
55945576
"icon": "$(gitlens-gitlens)",
@@ -5850,11 +5832,6 @@
58505832
]
58515833
}
58525834
},
5853-
"gitlens.views.addPullRequestRemote": {
5854-
"label": "Add Pull Request Remote",
5855-
"icon": "$(add)",
5856-
"enablement": "!operationInProgress"
5857-
},
58585835
"gitlens.views.addRemote": {
58595836
"label": "Add Remote...",
58605837
"icon": "$(add)",
@@ -9392,7 +9369,14 @@
93929369
}
93939370
},
93949371
"gitlens.views.launchpad.copy": {
9395-
"label": "Copy"
9372+
"label": "Copy",
9373+
"keybindings": [
9374+
{
9375+
"key": "ctrl+c",
9376+
"when": "focusedView == gitlens.views.launchpad",
9377+
"mac": "cmd+c"
9378+
}
9379+
]
93969380
},
93979381
"gitlens.views.launchpad.info": {
93989382
"label": "Learn about Launchpad...",
@@ -9793,9 +9777,6 @@
97939777
]
97949778
}
97959779
},
9796-
"gitlens.views.loadMoreChildren": {
9797-
"label": "Load More"
9798-
},
97999780
"gitlens.views.mergeBranchInto": {
98009781
"label": "Merge Branch into Current Branch...",
98019782
"enablement": "!operationInProgress",

package.json

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6340,11 +6340,6 @@
63406340
"command": "gitlens.ai.switchProvider:scm",
63416341
"title": "Switch GitLens AI Provider/Model..."
63426342
},
6343-
{
6344-
"command": "gitlens.ai.undoGenerateRebase",
6345-
"title": "Undo AI Generated Changes (Preview)...",
6346-
"icon": "$(discard)"
6347-
},
63486343
{
63496344
"command": "gitlens.annotations.nextChange",
63506345
"title": "Next Change",
@@ -7531,10 +7526,6 @@
75317526
"title": "Open Changed Files",
75327527
"category": "GitLens"
75337528
},
7534-
{
7535-
"command": "gitlens.openCloudPatch",
7536-
"title": "Open Cloud Patch..."
7537-
},
75387529
{
75397530
"command": "gitlens.openCommitOnRemote",
75407531
"title": "Open Commit on Remote",
@@ -7858,11 +7849,6 @@
78587849
"title": "Open in Commit Graph",
78597850
"icon": "$(gitlens-graph)"
78607851
},
7861-
{
7862-
"command": "gitlens.showInCommitGraphView",
7863-
"title": "Open in Commit Graph",
7864-
"icon": "$(gitlens-graph)"
7865-
},
78667852
{
78677853
"command": "gitlens.showInDetailsView",
78687854
"title": "Inspect Details",
@@ -7908,7 +7894,8 @@
79087894
},
79097895
{
79107896
"command": "gitlens.showQuickCommitDetails",
7911-
"title": "Quick Show Commit"
7897+
"title": "Quick Show Commit",
7898+
"category": "GitLens"
79127899
},
79137900
{
79147901
"command": "gitlens.showQuickCommitFileDetails",
@@ -8041,11 +8028,6 @@
80418028
"title": "Open View Settings",
80428029
"icon": "$(gear)"
80438030
},
8044-
{
8045-
"command": "gitlens.showSettingsPage!views",
8046-
"title": "Open Settings",
8047-
"icon": "$(gear)"
8048-
},
80498031
{
80508032
"command": "gitlens.showSettingsPage!worktrees-view",
80518033
"title": "Open View Settings",
@@ -8278,11 +8260,6 @@
82788260
"title": "Toggle File Changes",
82798261
"icon": "$(gitlens-gitlens)"
82808262
},
8281-
{
8282-
"command": "gitlens.toggleFileChangesOnly",
8283-
"title": "Toggle File Changes",
8284-
"icon": "$(gitlens-gitlens)"
8285-
},
82868263
{
82878264
"command": "gitlens.toggleFileHeatmap",
82888265
"title": "Toggle File Heatmap",
@@ -8381,12 +8358,6 @@
83818358
"title": "Add Co-authors...",
83828359
"icon": "$(person-add)"
83838360
},
8384-
{
8385-
"command": "gitlens.views.addPullRequestRemote",
8386-
"title": "Add Pull Request Remote",
8387-
"icon": "$(add)",
8388-
"enablement": "!operationInProgress"
8389-
},
83908361
{
83918362
"command": "gitlens.views.addRemote",
83928363
"title": "Add Remote...",
@@ -9140,10 +9111,6 @@
91409111
"title": "Load All",
91419112
"icon": "$(gitlens-expand)"
91429113
},
9143-
{
9144-
"command": "gitlens.views.loadMoreChildren",
9145-
"title": "Load More"
9146-
},
91479114
{
91489115
"command": "gitlens.views.mergeBranchInto",
91499116
"title": "Merge Branch into Current Branch...",
@@ -11124,10 +11091,6 @@
1112411091
"command": "gitlens.ai.switchProvider:scm",
1112511092
"when": "false"
1112611093
},
11127-
{
11128-
"command": "gitlens.ai.undoGenerateRebase",
11129-
"when": "false"
11130-
},
1113111094
{
1113211095
"command": "gitlens.annotations.nextChange",
1113311096
"when": "false"
@@ -12064,10 +12027,6 @@
1206412027
"command": "gitlens.openChangedFiles",
1206512028
"when": "gitlens:enabled"
1206612029
},
12067-
{
12068-
"command": "gitlens.openCloudPatch",
12069-
"when": "false"
12070-
},
1207112030
{
1207212031
"command": "gitlens.openCommitOnRemote",
1207312032
"when": "gitlens:repos:withRemotes"
@@ -12288,10 +12247,6 @@
1228812247
"command": "gitlens.showInCommitGraph",
1228912248
"when": "false"
1229012249
},
12291-
{
12292-
"command": "gitlens.showInCommitGraphView",
12293-
"when": "false"
12294-
},
1229512250
{
1229612251
"command": "gitlens.showInDetailsView",
1229712252
"when": "false"
@@ -12326,7 +12281,7 @@
1232612281
},
1232712282
{
1232812283
"command": "gitlens.showQuickCommitDetails",
12329-
"when": "false"
12284+
"when": "resource in gitlens:tabs:blameable"
1233012285
},
1233112286
{
1233212287
"command": "gitlens.showQuickCommitFileDetails",
@@ -12420,10 +12375,6 @@
1242012375
"command": "gitlens.showSettingsPage!tags-view",
1242112376
"when": "false"
1242212377
},
12423-
{
12424-
"command": "gitlens.showSettingsPage!views",
12425-
"when": "false"
12426-
},
1242712378
{
1242812379
"command": "gitlens.showSettingsPage!worktrees-view",
1242912380
"when": "false"
@@ -12588,10 +12539,6 @@
1258812539
"command": "gitlens.toggleFileChanges:editor/title",
1258912540
"when": "false"
1259012541
},
12591-
{
12592-
"command": "gitlens.toggleFileChangesOnly",
12593-
"when": "false"
12594-
},
1259512542
{
1259612543
"command": "gitlens.toggleFileHeatmap",
1259712544
"when": "resource in gitlens:tabs:blameable || config.gitlens.heatmap.toggleMode == window"
@@ -12668,10 +12615,6 @@
1266812615
"command": "gitlens.views.addAuthors",
1266912616
"when": "false"
1267012617
},
12671-
{
12672-
"command": "gitlens.views.addPullRequestRemote",
12673-
"when": "false"
12674-
},
1267512618
{
1267612619
"command": "gitlens.views.addRemote",
1267712620
"when": "false"
@@ -13296,10 +13239,6 @@
1329613239
"command": "gitlens.views.loadAllChildren",
1329713240
"when": "false"
1329813241
},
13299-
{
13300-
"command": "gitlens.views.loadMoreChildren",
13301-
"when": "false"
13302-
},
1330313242
{
1330413243
"command": "gitlens.views.mergeBranchInto",
1330513244
"when": "false"
@@ -24183,6 +24122,12 @@
2418324122
"when": "focusedView == gitlens.views.fileHistory",
2418424123
"mac": "cmd+c"
2418524124
},
24125+
{
24126+
"command": "gitlens.views.launchpad.copy",
24127+
"key": "ctrl+c",
24128+
"when": "focusedView == gitlens.views.launchpad",
24129+
"mac": "cmd+c"
24130+
},
2418624131
{
2418724132
"command": "gitlens.views.lineHistory.copy",
2418824133
"key": "ctrl+c",

scripts/generateCommandTypes.mts

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,81 @@ function generateCommandTypesFromContributions(): void {
1616
readFileSync(path.join(__dirname, 'contributions.json'), 'utf8'),
1717
);
1818

19-
const commands: string[] = [];
20-
const kbCommands: string[] = [];
21-
const paletteCommands: string[] = [];
19+
const commands = new Set<string>();
20+
const paletteCommands = new Set<string>();
21+
const kbCommands = new Set<string>();
22+
const internalCommands = new Set<string>();
2223

24+
let internal: boolean;
2325
for (const [id, command] of Object.entries(contributions.commands)) {
26+
internal = true;
27+
if (command.menus) {
28+
internal = false;
29+
commands.add(id);
30+
31+
for (const menus of Object.values(command.menus)) {
32+
for (const menu of menus) {
33+
if (menu.alt) {
34+
commands.add(menu.alt);
35+
}
36+
}
37+
}
38+
}
39+
2440
if (command.commandPalette) {
25-
paletteCommands.push(id);
26-
} else {
27-
commands.push(id);
41+
internal = false;
42+
paletteCommands.add(id);
43+
}
44+
45+
if (command.keybindings) {
46+
internal = false;
47+
kbCommands.add(id);
48+
}
49+
50+
if (internal) {
51+
internalCommands.add(id);
2852
}
2953
}
3054

3155
for (const kb of contributions.keybindings) {
32-
kbCommands.push(kb.command);
56+
kbCommands.add(kb.command);
57+
}
58+
59+
// Remove from internal any commands that are in other lists
60+
for (const id of [...commands, ...paletteCommands, ...kbCommands]) {
61+
internalCommands.delete(id);
3362
}
3463

3564
const contents = `// This file is generated by (vscode-gitlens)/${relativeFilename}
3665
// Do not edit this file directly
3766
38-
export type ContributedCommands = ContributedKeybindingCommands | ContributedPaletteCommands | ${commands
67+
export type ContributedCommands = ContributedKeybindingCommands | ContributedPaletteCommands | ContributedOrphansOrInternalCommands | ${[
68+
...commands,
69+
]
3970
.sort()
4071
.map(c => `'${c}'`)
4172
.join(' | ')};
4273
43-
export type ContributedPaletteCommands = ${paletteCommands
74+
export type ContributedPaletteCommands = ${[...paletteCommands]
4475
.sort()
4576
.map(c => `'${c}'`)
4677
.join(' | ')};
4778
48-
export type ContributedKeybindingCommands = ${kbCommands
79+
export type ContributedKeybindingCommands = ${[...kbCommands]
4980
.filter(c => c.startsWith('gitlens.'))
5081
.sort()
5182
.map(c => `'${c}'`)
5283
.join(' | ')};
5384
85+
/**
86+
* Commands that are not contributed anywhere, not the command palette, menus (or alts), nor keybindings.
87+
* Either their contribution point is missing or are simply internal and should be removed at some point
88+
*/
89+
export type ContributedOrphansOrInternalCommands = ${[...internalCommands]
90+
.sort()
91+
.map(c => `'${c}'`)
92+
.join(' | ')};
93+
5494
`;
5595

5696
const file = path.join(__dirname, 'src', 'constants.commands.generated.ts');

0 commit comments

Comments
 (0)