Files
Inbox/Git/一个给AI用的Commit信息约束文件.md
2025-12-11 07:24:36 +08:00

82 lines
2.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
tags: []
aliases:
- AI Git 协作与提交规范 (Context for AI)
date created: 星期四, 十二月 4日 2025, 8:24:48 晚上
date modified: 星期四, 十二月 4日 2025, 8:28:44 晚上
---
# AI Git 协作与提交规范 (Context for AI)
本文件定义了 RadarSimulator 项目的 Git 协作规则。作为 AI 助手,在生成提交信息、分支名称或 PR 描述时,**必须严格遵守**以下约束。
## 1. 分支命名规范 (Branch Naming)
- **开发基准分支**: `develop` (禁止直接推送)
- **生产分支**: `main` (禁止直接推送)
- **工作分支 (Feature Branch)**:
    * 格式: `feature/<description-in-kebab-case>`
    * 要求: 全小写,使用连字符分隔,推荐关联 Issue。
    * 示例: `feature/add-tsc-timer`, `feature/fix-udp-buffer-overflow`
## 2. 提交信息规范 (Commit Message)
必须遵循 **Conventional Commits** 标准。
### 2.1 格式模板
```text
<type>(<scope>): <subject> (#<IssueID>)
[body] (可选)
```
### 2.2 字段约束
1. **`<type>` (枚举,严格限制):**
      * `feat`: 新功能 (Features)
      * `fix`: Bug 修复 (Bug Fixes)
      * `docs`: 文档变更 (Documentation)
      * `style`: 格式调整 (不影响代码逻辑,如空格、分号)
      * `refactor`: 代码重构 (即不是新增功能,也不是修改 bug)
      * `test`: 增加测试或修改现有测试
      * `chore`: 构建过程或辅助工具的变动 (如 CMake, Docker, gitignore)
1. **`<scope>` (可选):**
      * 描述修改的模块。
      * 常见值: `core`, `tools`, `sim`, `ci`, `parser`, `common`.
1. **`<subject>` (必需):**
      * **语言**: **中文**
      * 时态: 使用现在时 (如 " 添加…", " 修复…")。
      * 格式: 结尾**不要**加句号。
1. **`(#<IssueID>)` (可选):**
      * 如果有 ID请关联 Issue ID。如果用户未提供请主动询问并提示用户填写。
### 2.3 示例
  * `feat(core): 实现基于 TSC 的高精度计时器 (#128)`
  * `fix(tools): 修正接收端缓冲区溢出问题 (#129)`
  * `chore(ci): 移除 Dockerfile 冗余步骤 (#130)`
## 3\. 工作流约束 (Workflow Constraints)
1. **原子性提交 (Atomic Commits)**: 不要将不相关的修改混入同一个 Commit。AI 在分析 Diff 时,若发现多个不相关的改动,应建议拆分为多个 Commits。
2. **Pull Request 标题**: 必须与 Commit Message 格式保持一致。