Skip to content

Commit cbdc210

Browse files
committed
feat(配置): 增智能暂存之配置
- 增新配置 `wtfCommit.smartStage`,以避误提交之虞 - 若暂存区空,可禁自动暂存,默许旧行 - 更新版本至 0.0.10,并录于更易日志 - 更英文及中文文档,以明新能
1 parent a76b229 commit cbdc210

5 files changed

Lines changed: 23 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to the "wtf-commit" extension will be documented in this fil
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.10] - 2026-01-12
9+
### Added
10+
- New configuration `wtfCommit.smartStage`:
11+
- Prevents accidental commits by allowing users to disable auto-staging when the staging area is empty.
12+
- Default is `true` (maintain existing behavior).
13+
- If set to `false`, an error will be shown if you try to commit with an empty staging area.
14+
815
## [0.0.9] - 2026-01-12
916
### Added
1017
- Enhanced Multi-language support:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Most settings have sensible defaults. You only need to change them if you want t
5050
| **Auto Commit** | Automatically commit after generating the message. |
5151
| **Auto Push** | Automatically push after commit (requires Auto Commit). |
5252
| **Confirm Before Commit** | Show confirmation dialog before auto-committing. |
53+
| **Smart Stage** | Automatically stage all working tree changes if nothing is staged (Default: `true`). |
5354
| **Prompt** | The system prompt used by AI. |
5455
| **Language** | Choose between `English`, `简体中文`, `繁体中文`, `Japanese`, `Classical Chinese (文言文)`, or `Custom`. |
5556
| **Custom Language** | Enter any language description (e.g., `French`, `Emoji only`) when **Language** is set to `Custom`. |

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ WTF Commit 是一款简约的 VS Code 扩展,利用 AI 根据您暂存的更
4949
| **Auto Commit** | 生成信息后自动提交。 |
5050
| **Auto Push** | 提交后自动推送(需要开启 Auto Commit)。 |
5151
| **Confirm Before Commit** | 自动提交前显示确认对话框。 |
52+
| **Smart Stage** | 当暂存区为空时,自动将工作区所有变更加入暂存区(默认:`true`)。 |
5253
| **Prompt** | AI 使用的系统提示词。 |
5354
| **Language** | 可选择 `English`, `简体中文`, `繁体中文`, `Japanese`, `Classical Chinese (文言文)``Custom`|
5455
| **Custom Language** |**Language** 设置为 `Custom` 时,可手动输入任何语言描述(如 `French`, `Emoji only`, `粤语`)。 |

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "wtf-commit",
33
"displayName": "WTF Commit",
44
"description": "AI-powered Git commit message generator",
5-
"version": "0.0.9",
5+
"version": "0.0.10",
66
"license": "MIT",
77
"publisher": "codertesla",
88
"icon": "icon.png",
@@ -62,6 +62,12 @@
6262
"description": "Automatically push changes after commit (requires autoCommit to be enabled).",
6363
"order": 0
6464
},
65+
"wtfCommit.smartStage": {
66+
"type": "boolean",
67+
"default": true,
68+
"description": "Automatically stage all changes if nothing is staged.",
69+
"order": 0
70+
},
6571
"wtfCommit.confirmBeforeCommit": {
6672
"type": "boolean",
6773
"default": true,

src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export function activate(context: vscode.ExtensionContext) {
9191
const customLanguage = config.get<string>('customLanguage') || 'English';
9292
const autoCommit = config.get<boolean>('autoCommit') || false;
9393
const autoPush = config.get<boolean>('autoPush') || false;
94+
const smartStage = config.get<boolean>('smartStage') ?? true;
9495
const confirmBeforeCommit = config.get<boolean>('confirmBeforeCommit') ?? true;
9596
let systemPrompt = config.get<string>('prompt') || 'You are an expert software developer. Generate a clear and concise Git commit message based on the provided diff.';
9697

@@ -186,7 +187,12 @@ export function activate(context: vscode.ExtensionContext) {
186187
if (hasStagedChanges) {
187188
diff = await repository.diff(true); // cached = true for staged changes
188189
} else if (hasWorkingTreeChanges) {
189-
diff = await repository.diff(false); // cached = false for working tree changes
190+
if (smartStage) {
191+
diff = await repository.diff(false); // cached = false for working tree changes
192+
} else {
193+
vscode.window.showErrorMessage('No staged changes found. Please stage your changes first.');
194+
return;
195+
}
190196
} else {
191197
vscode.window.showInformationMessage('No changes to commit.');
192198
return;

0 commit comments

Comments
 (0)