feat: preserve Change-Id in amend mode#15
Conversation
1. Added extract_change_id function to parse Change-Id from existing commit messages 2. Added append_change_id function to add Change-Id to new commit messages when not present 3. Modified build_prompt to accept original commit message parameter for reference in amend mode 4. Updated generate_commit_message to extract original Change-Id in amend mode and preserve it in new commit message 5. Added original commit message to AI prompt for better context in amend mode 6. Added comprehensive unit tests for Change-Id extraction and appending functions Log: Improved commit message generation in amend mode to preserve Change-Id and reference original message Influence: 1. Test amend mode with existing Change-Id to ensure it's preserved 2. Test amend mode without Change-Id to ensure no extra Change-Id is added 3. Verify AI generates improved commit messages while referencing original content 4. Test Change-Id extraction with various message formats 5. Verify Change-Id appending logic handles edge cases properly 6. Test commit message generation with and without other metadata tags feat: 在 amend 模式下保留 Change-Id 1. 添加 extract_change_id 函数从现有提交消息中解析 Change-Id 2. 添加 append_change_id 函数在提交消息不存在 Change-Id 时添加 3. 修改 build_prompt 函数以接受原始提交消息参数,用于 amend 模式下的参考 4. 更新 generate_commit_message 函数在 amend 模式下提取原始 Change-Id 并 保留到新提交消息中 5. 将原始提交消息添加到 AI 提示词中,为 amend 模式提供更好的上下文 6. 添加全面的单元测试,覆盖 Change-Id 提取和添加功能 Log: 改进 amend 模式下的提交消息生成,保留 Change-Id 并参考原始消息 Influence: 1. 测试带有现有 Change-Id 的 amend 模式,确保 Change-Id 被保留 2. 测试没有 Change-Id 的 amend 模式,确保不会添加额外的 Change-Id 3. 验证 AI 在参考原始内容的同时生成改进的提交消息 4. 测试不同消息格式下的 Change-Id 提取功能 5. 验证 Change-Id 添加逻辑正确处理边界情况 6. 测试带有和不带有其他元数据标签的提交消息生成
There was a problem hiding this comment.
Pull request overview
This PR enhances the amend mode functionality to preserve Change-Id metadata from original commits and provides the original commit message as context to the AI for better suggestions.
Changes:
- Added
extract_change_id()andappend_change_id()helper functions to handle Change-Id metadata - Modified
build_prompt()to accept and incorporate original commit messages in amend mode - Updated
generate_commit_message()to extract and preserve Change-Id, and pass original context to AI - Added comprehensive unit tests for the new Change-Id handling functions
| /// 从提交消息中提取 Change-Id | ||
| fn extract_change_id(message: &str) -> Option<String> { |
There was a problem hiding this comment.
Consider adding English documentation for this function in addition to the Chinese comment, consistent with project patterns where functions have bilingual documentation or English documentation for better maintainability.
| /// 将 Change-Id 添加到提交消息中(如果还没有的话) | ||
| fn append_change_id(message: &str, change_id: &str) -> String { |
There was a problem hiding this comment.
Consider adding English documentation for this function in addition to the Chinese comment, consistent with project patterns where functions have bilingual documentation or English documentation for better maintainability.
在 amend 模式下新增两个功能:
Log: Improved commit message generation in amend mode to preserve Change-Id and reference original message
Influence:
feat: 在 amend 模式下保留 Change-Id
Log: 改进 amend 模式下的提交消息生成,保留 Change-Id 并参考原始消息
Influence: