Skip to content

Commit 13d49f8

Browse files
committed
✨ Add command gptcommit.showPerFileSummary (gptcommit 0.5.x)
1 parent 5879d91 commit 13d49f8

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
{
4747
"command": "gptcommit.setOutputLanguage",
4848
"title": "GPTCommit: Set output language"
49+
},
50+
{
51+
"command": "gptcommit.showPerFileSummary",
52+
"title": "GPTCommit: Show per-file summary"
4953
}
5054
],
5155
"menus": {
@@ -81,16 +85,16 @@
8185
"enum": [
8286
"title",
8387
"title + summary",
84-
"title + breakdown",
85-
"title + summary + breakdown"
88+
"title + per-file",
89+
"title + summary + per-file"
8690
],
8791
"enumDescriptions": [
8892
"Only the title",
8993
"Title and bullet-point summary",
90-
"Title and breakdown of each changed file",
91-
"Title, bullet-point summary and each changed file"
94+
"Title and per-file summary",
95+
"Title, bullet-point summary and per-file summary"
9296
],
93-
"description": "Content of the message to fill in the express mode."
97+
"description": "Content of the message to fill in the express mode. Note that you need enable per-file summary for the per-file content (by GPTCommit: Show per-file summary)."
9498
},
9599
"gptcommit.onFiles": {
96100
"type": "string",

src/commands/createCommandConfigs.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export function setupOpenAIApiKey(context: vscode.ExtensionContext, channel: vsc
66
vscode.window.showInputBox({
77
prompt: 'Enter your OpenAI API key',
88
placeHolder: 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
9+
ignoreFocusOut: true,
910
}).then((key) => {
1011
if (key) {
1112
saveConfig(
@@ -28,6 +29,7 @@ export function useDifferentModel(context: vscode.ExtensionContext, channel: vsc
2829
vscode.window.showInputBox({
2930
prompt: 'Enter the model you want to use',
3031
placeHolder: 'gpt-3.5-turbo',
32+
ignoreFocusOut: true,
3133
}).then((model) => {
3234
if (model) {
3335
saveConfig(
@@ -50,6 +52,7 @@ export function setOutputLanguage(context: vscode.ExtensionContext, channel: vsc
5052
vscode.window.showInputBox({
5153
prompt: 'Enter the language of the generated commit message',
5254
placeHolder: 'en',
55+
ignoreFocusOut: true,
5356
}).then((lang) => {
5457
if (lang) {
5558
saveConfig(
@@ -66,3 +69,28 @@ export function setOutputLanguage(context: vscode.ExtensionContext, channel: vsc
6669

6770
context.subscriptions.push(languageCommand);
6871
}
72+
73+
export function showPerFileSummary(context: vscode.ExtensionContext, channel: vscode.OutputChannel) {
74+
let showPerFileCommand = vscode.commands.registerCommand('gptcommit.showPerFileSummary', async (uri?: vscode.SourceControl) => {
75+
vscode.window.showQuickPick(
76+
["Yes", "No"],
77+
{
78+
placeHolder: 'Enable "show per-file summary"?',
79+
ignoreFocusOut: true,
80+
}
81+
).then((show) => {
82+
if (show === "Yes" || show === "No") {
83+
saveConfig(
84+
'output.show_per_file_summary',
85+
'output.show_per_file_summary',
86+
channel,
87+
getRepo(uri),
88+
show === "Yes" ? "true" : "false",
89+
'Configuration show per-file summary saved'
90+
);
91+
}
92+
});
93+
});
94+
95+
context.subscriptions.push(showPerFileCommand);
96+
}

src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
// Import the module and reference it with the alias vscode in your code below
33
import * as vscode from 'vscode';
44
import createCommandGenerateGitCommitMessage from './commands/createCommandGenerateGitCommitMessage';
5-
import { setupOpenAIApiKey, useDifferentModel, setOutputLanguage } from './commands/createCommandConfigs';
5+
import {
6+
setupOpenAIApiKey,
7+
useDifferentModel,
8+
setOutputLanguage,
9+
showPerFileSummary,
10+
} from './commands/createCommandConfigs';
611

712
// This method is called when your extension is activated
813
// Your extension is activated the very first time the command is executed
@@ -22,6 +27,7 @@ export function activate(context: vscode.ExtensionContext) {
2227
setupOpenAIApiKey(context, channel);
2328
useDifferentModel(context, channel);
2429
setOutputLanguage(context, channel);
30+
showPerFileSummary(context, channel);
2531
}
2632

2733
// This method is called when your extension is deactivated

0 commit comments

Comments
 (0)