feat: 拆分评审与提交消息提示词并增加 hook 备份与 JSON 输出
- 新增 custom_reviewer_prompt 和 custom_commit_msg_prompt,兼容旧 custom_prompt - pre-commit hook 安装时备份已有 hook,卸载时恢复 - 支持 --format json 输出评审结果 - diff 发送前自动脱敏敏感信息
This commit is contained in:
1 parent
39c58316a5
commit
b04d70b99a
18 files changed
+637
-45
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package reviewer
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseReviewReport(t *testing.T) {
|
||||
raw := `#### 详细审查意见
|
||||
- [BLOCKER] internal/user.go:45 - 存在 SQL 注入风险
|
||||
- [WARNING] internal/user.go:82 - Redis 错误被忽略
|
||||
- [WARNING] 缺少超时控制
|
||||
#### 评审结论
|
||||
- 结论: [REJECT]
|
||||
- 评分: 58 / 100
|
||||
`
|
||||
|
||||
report := ParseReviewReport(raw)
|
||||
if report.Verdict != "REJECT" || report.Score != 58 {
|
||||
t.Fatalf("结论解析错误: %+v", report)
|
||||
}
|
||||
if len(report.Findings) != 3 || report.Findings[0].Location != "internal/user.go:45" {
|
||||
t.Fatalf("问题解析错误: %+v", report.Findings)
|
||||
}
|
||||
if report.Findings[2].Location != "" || report.Findings[2].Message != "缺少超时控制" {
|
||||
t.Fatalf("无位置信息的问题解析错误: %+v", report.Findings[2])
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user