Skip to content

Commit 9833258

Browse files
committed
[copilot]:Improve the copilot guide
1 parent d80c211 commit 9833258

File tree

1 file changed

+160
-15
lines changed

1 file changed

+160
-15
lines changed

.github/copilot-instructions.md

Lines changed: 160 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ RT-Thread is a real-time operating system (RTOS) for embedded devices. When work
66

77
RT-Thread 是一个面向嵌入式设备的实时操作系统(RTOS)。在处理 RT-Thread 代码时,请遵循以下指南以确保高质量的贡献。
88

9+
**When reviewing Pull Requests (PRs), you MUST check all items in the PR Review Checklist section and provide feedback according to the PR Review Instructions. / 在审查 Pull Request (PR) 时,必须检查 PR 审查清单部分中的所有项目,并根据 PR 审查指令提供反馈。**
10+
911
## Code Review Guidelines / 代码审查指南
1012

1113
### Language Requirements / 语言要求
@@ -26,21 +28,162 @@ When reviewing code, provide feedback in **both English and Chinese** to ensure
2628
- Follow RT-Thread coding standards / 遵循 RT-Thread 编码标准
2729
- Maintain consistent naming conventions / 保持一致的命名约定
2830
- Ensure proper code comments (not documentation) / 确保适当的代码注释(而非文档)
29-
4. **PR Title Naming Guidelines / PR 标题命名规范**
30-
- **Specify the module or keyword / 明确模块或关键字**
31-
- 标题需明确指出涉及的具体模块、子系统或关键字,例如具体的 BSP(Board Support Package)或芯片厂商名称(如 STM32, ESP32, NXP 等)。
32-
- 示例:[STM32][I2C] Fix Kconfig parsing error 而非 fix:I2C——Kconfig修改。
33-
- **Clearly describe the content being repaired or modified / 清晰描述修复或更改内容**
34-
- 标题需简洁清晰地描述修复的问题、添加的功能或修改的内容,避免模糊或过于简略的描述。
35-
- 示例:[STM32][SPI] Fix buffer overflow in SPI driver 而非 SPI bug fix。
36-
- **Format Recommendations / 格式建议**
37-
- 推荐使用 [模块/厂商][子系统] 具体描述 的格式,确保标题结构化且信息完整。
38-
- 使用英文描述问题(除非项目明确要求使用其他语言),以提高国际化可读性。
39-
- 示例:[NXP][UART] Add timeout handling for UART receive。
40-
- **Issues to Avoid / 避免的问题**
41-
- 不要使用模糊的术语,如“修复问题”或“代码优化”,需具体说明问题或优化的内容。
42-
- 避免使用不规范的符号(如 ——),建议使用标准英文字符(如 - 或 :)。
43-
- 不要省略关键上下文信息,如 BSP 或芯片厂商。
31+
4. **PR Review Checklist / PR 审查清单**
32+
- **PR Title Review / PR 标题审查**
33+
- Check if PR title has proper prefix format / 检查 PR 标题是否有正确的前缀格式
34+
- Verify prefix follows pattern: `[module/vendor][subsystem]` or `[module/vendor]` in lowercase / 验证前缀遵循格式:小写的 `[模块/厂商][子系统]``[模块/厂商]`
35+
- Verify title describes changes based on modified files / 验证标题基于修改的文件描述变更
36+
- Check if title is specific enough (avoid vague terms like "fix bug", "optimize code") / 检查标题是否足够具体(避免模糊术语如"修复问题"、"代码优化")
37+
- If title lacks prefix or uses incorrect format, suggest: "PR title should follow format: `[module][subsystem] Description`. Example: `[stm32][drivers] Fix UART interrupt handling issue`" / 如果标题缺少前缀或格式错误,建议:"PR 标题应遵循格式:`[模块][子系统] 描述`。示例:`[stm32][drivers] Fix UART interrupt handling issue`"
38+
- **PR Description Review / PR 内容审查**
39+
- Check if PR description provides overview of modified files / 检查 PR 描述是否提供了修改文件的总概
40+
- Verify description explains: What (what changes), Why (why needed), How (which files modified) / 验证描述是否说明:What(做了什么修改)、Why(为什么需要)、How(修改了哪些文件)
41+
- If description is missing or insufficient, suggest adding description with modified files list / 如果描述缺失或不充分,建议添加包含修改文件列表的描述
42+
- **PR File Modification Review / PR 修改文件审查**
43+
- Check if PR contains multiple unrelated features / 检查 PR 是否包含多个不相关的特性
44+
- If PR mixes multiple features, suggest splitting into separate PRs / 如果 PR 混杂多个特性,建议拆分为多个 PR
45+
- Verify all file changes are related to the same feature/bug fix / 验证所有文件修改是否与同一功能/错误修复相关
46+
- **PR Commit Review / PR Commit 审查**
47+
- Check commit message format (should follow PR title format) / 检查 commit 消息格式(应遵循 PR 标题格式)
48+
- Verify if commits are properly organized / 验证 commit 是否组织得当
49+
- If routine changes (style fixes, minor bugs, docs, typos) are split into multiple commits, suggest squashing them / 如果常规修改(风格修复、小错误、文档、拼写)被拆分为多个 commit,建议压缩它们
50+
- Important commits (major features, refactoring, critical bugs) can remain separate / 重要提交(主要功能、重构、关键错误)可以保持独立
51+
- If commit messages don't follow format, suggest: "Commit message should follow format: `[module][subsystem] Description`. Consider squashing routine changes into one commit." / 如果 commit 消息不符合格式,建议:"Commit 消息应遵循格式:`[模块][子系统] 描述`。考虑将常规修改压缩为一个 commit。"
52+
53+
### PR Review Instructions / PR 审查指令
54+
55+
**When reviewing a PR, you MUST systematically check the following items and provide feedback for any violations / 审查 PR 时,必须系统性地检查以下项目,并对任何违规行为提供反馈:**
56+
57+
#### Step 1: PR Title Check / 步骤 1:PR 标题检查
58+
59+
1. **Check prefix format / 检查前缀格式**:
60+
- Extract the PR title from the PR / 从 PR 中提取 PR 标题
61+
- Verify if it starts with `[module][subsystem]` or `[module]` pattern in lowercase / 验证是否以小写的 `[模块][子系统]``[模块]` 格式开头
62+
- Check if prefix matches the modified files (e.g., if files are in `bsp/stm32/drivers/`, prefix should be `[stm32][drivers]` or similar) / 检查前缀是否与修改的文件匹配(例如,如果文件在 `bsp/stm32/drivers/`,前缀应为 `[stm32][drivers]` 或类似)
63+
- If prefix is missing, incorrect case (e.g., `[STM32]`), or doesn't match files, provide feedback / 如果前缀缺失、大小写错误(如 `[STM32]`)或不匹配文件,提供反馈
64+
- **Feedback template / 反馈模板**:
65+
```
66+
🟡 [PR Title/PR 标题]: Missing or incorrect prefix format / 缺少或错误的前缀格式
67+
68+
English: PR title should follow format: `[module][subsystem] Description` in lowercase.
69+
Current title: `{current_title}`.
70+
Based on modified files, suggested title: `{suggested_title}`.
71+
72+
中文:PR 标题应遵循格式:小写的 `[模块][子系统] 描述`。
73+
当前标题:`{current_title}`。
74+
基于修改的文件,建议标题:`{suggested_title}`。
75+
```
76+
77+
2. **Check title specificity / 检查标题具体性**:
78+
- Analyze modified files to understand what changes were made / 分析修改的文件以了解所做的更改
79+
- Verify if title accurately describes changes based on modified files / 验证标题是否基于修改的文件准确描述更改
80+
- Check for vague terms: "fix bug", "optimize code", "update", "modify", etc. / 检查模糊术语:"修复问题"、"代码优化"、"更新"、"修改"等
81+
- If title is vague or doesn't match modified files, suggest a more specific title / 如果标题模糊或不匹配修改的文件,建议更具体的标题
82+
- **Feedback template / 反馈模板**:
83+
```
84+
🟡 [PR Title/PR 标题]: Title is too vague or doesn't match modified files / 标题过于模糊或不匹配修改的文件
85+
86+
English: PR title should specifically describe changes based on modified files.
87+
Current title: `{current_title}`.
88+
Suggested: `{suggested_title}` based on files: {list_modified_files}.
89+
90+
中文:PR 标题应基于修改的文件具体描述更改。
91+
当前标题:`{current_title}`。
92+
建议:基于文件 {list_modified_files} 的 `{suggested_title}`。
93+
```
94+
95+
#### Step 2: PR Description Check / 步骤 2:PR 内容检查
96+
97+
1. **Check description completeness / 检查描述完整性**:
98+
- Read the PR description / 阅读 PR 描述
99+
- Verify if it includes: / 验证是否包含:
100+
- Overview of modified files / 修改文件的总概
101+
- What changes were made / 做了什么修改
102+
- Why changes are needed / 为什么需要这些修改
103+
- List of modified files (optional but recommended) / 修改文件列表(可选但推荐)
104+
- If description is missing, empty, or insufficient, provide feedback / 如果描述缺失、为空或不充分,提供反馈
105+
- **Feedback template / 反馈模板**:
106+
```
107+
🟢 [PR Description/PR 描述]: Missing or insufficient description / 缺少或不充分的描述
108+
109+
English: PR description should include: (1) Overview of modified files, (2) What changes were made, (3) Why changes are needed, (4) List of modified files (optional).
110+
Please add/modify the PR description.
111+
112+
中文:PR 描述应包含:(1) 修改文件的总概,(2) 做了什么修改,(3) 为什么需要这些修改,(4) 修改文件列表(可选)。
113+
请添加/修改 PR 描述。
114+
115+
Example format / 示例格式:
116+
## Description / 描述
117+
This PR fixes the UART interrupt handling issue in STM32 serial driver.
118+
本次 PR 修复了 STM32 串口驱动中的中断处理问题。
119+
120+
## Modified Files / 修改文件
121+
- `bsp/stm32/drivers/drv_usart.c`: Fixed interrupt handler logic
122+
- `bsp/stm32/drivers/drv_usart.h`: Updated function declarations
123+
```
124+
125+
#### Step 3: PR File Modification Check / 步骤 3:PR 修改文件检查
126+
127+
1. **Check feature separation / 检查特性分离**:
128+
- List all modified files in the PR / 列出 PR 中的所有修改文件
129+
- Group files by feature/functionality / 按特性/功能对文件进行分组
130+
- Identify if multiple unrelated features are mixed / 识别是否混杂了多个不相关的特性
131+
- Unrelated features include: different drivers, different subsystems, unrelated bug fixes, etc. / 不相关的特性包括:不同的驱动、不同的子系统、不相关的错误修复等
132+
- If multiple unrelated features are found, provide feedback with specific suggestions / 如果发现多个不相关的特性,提供具体建议的反馈
133+
- **Feedback template / 反馈模板**:
134+
```
135+
🟡 [PR Structure/PR 结构]: Multiple unrelated features in one PR / 一个 PR 中包含多个不相关的特性
136+
137+
English: This PR contains multiple unrelated features: {list_features}.
138+
Please split into separate PRs, each focusing on one feature.
139+
Suggested PRs:
140+
- PR 1: `[module1][subsystem1] {feature1_description}` (files: {list_files1})
141+
- PR 2: `[module2][subsystem2] {feature2_description}` (files: {list_files2})
142+
143+
中文:此 PR 包含多个不相关的特性:{list_features}。
144+
请拆分为多个 PR,每个专注于一个特性。
145+
建议的 PR:
146+
- PR 1: `[模块1][子系统1] {特性1描述}` (文件: {list_files1})
147+
- PR 2: `[模块2][子系统2] {特性2描述}` (文件: {list_files2})
148+
```
149+
150+
#### Step 4: PR Commit Check / 步骤 4:PR Commit 检查
151+
152+
1. **Check commit message format / 检查 commit 消息格式**:
153+
- Review all commit messages in the PR / 审查 PR 中的所有 commit 消息
154+
- Verify if each commit message follows format: `[module][subsystem] Description` / 验证每个 commit 消息是否遵循格式:`[module][subsystem] 描述`
155+
- Check if commit message prefix matches PR title prefix / 检查 commit 消息前缀是否与 PR 标题前缀匹配
156+
- If commit messages don't follow format, provide feedback / 如果 commit 消息不符合格式,提供反馈
157+
- **Feedback template / 反馈模板**:
158+
```
159+
🟡 [Commit Message/Commit 消息]: Commit message format violation / Commit 消息格式违规
160+
161+
English: Commit message should follow format: `[module][subsystem] Description`.
162+
Invalid commits: {list_invalid_commits}.
163+
Example: `[stm32][drivers] Fix UART interrupt handling issue`.
164+
165+
中文:Commit 消息应遵循格式:`[模块][子系统] 描述`。
166+
无效的 commit:{list_invalid_commits}。
167+
示例:`[stm32][drivers] Fix UART interrupt handling issue`。
168+
```
169+
170+
2. **Check commit organization / 检查 commit 组织**:
171+
- Identify routine changes: style fixes, minor bugs, documentation updates, typo corrections / 识别常规修改:风格修复、小错误、文档更新、拼写错误修正
172+
- Identify important changes: major features, significant refactoring, critical bug fixes / 识别重要更改:主要功能、重大重构、关键错误修复
173+
- Check if routine changes are split into multiple commits / 检查常规修改是否被拆分为多个 commit
174+
- If routine changes are split, suggest squashing them / 如果常规修改被拆分,建议压缩它们
175+
- **Feedback template / 反馈模板**:
176+
```
177+
🟢 [Commit Organization/Commit 组织]: Routine changes should be squashed / 常规修改应压缩
178+
179+
English: Routine changes (style fixes, minor bugs, docs, typos) should be squashed into one commit.
180+
Commits to squash: {list_commits_to_squash}.
181+
Please use `git rebase -i` to squash these commits.
182+
183+
中文:常规修改(风格修复、小错误、文档、拼写)应压缩为一个 commit。
184+
要压缩的 commit:{list_commits_to_squash}。
185+
请使用 `git rebase -i` 压缩这些 commit。
186+
```
44187
45188
### Review Comment Format / 审查评论格式
46189
@@ -59,6 +202,8 @@ Example/示例:
59202
// Your code example here / 你的代码示例
60203
```
61204
```
205+
206+
**For PR-related issues, use severity level 🟡 Minor or 🟢 Suggestion / 对于 PR 相关的问题,使用严重程度级别 🟡 Minor 或 🟢 Suggestion**
62207
### Common Issues to Check / 常见问题检查
63208
64209
1. **Resource Management / 资源管理**

0 commit comments

Comments
 (0)