You've already forked agentic-coding-workflow
refactor(project): issue Update tracks changed fields and skips no-op audit
This commit is contained in:
@@ -128,24 +128,26 @@ func (s *issueService) Update(ctx context.Context, c Caller, slug string, number
|
|||||||
}
|
}
|
||||||
|
|
||||||
title, desc := cur.Title, cur.Description
|
title, desc := cur.Title, cur.Description
|
||||||
if in.Title != nil {
|
changed := map[string]any{}
|
||||||
|
if in.Title != nil && *in.Title != cur.Title {
|
||||||
title = *in.Title
|
title = *in.Title
|
||||||
|
changed["title"] = "<changed>"
|
||||||
}
|
}
|
||||||
if in.Description != nil {
|
if in.Description != nil && *in.Description != cur.Description {
|
||||||
desc = *in.Description
|
desc = *in.Description
|
||||||
|
changed["description"] = "<changed>"
|
||||||
}
|
}
|
||||||
|
|
||||||
// requirement 三态:未传(in.RequirementNumber == nil)→ 保持
|
// requirement 三态:未传(in.RequirementNumber == nil)→ 保持
|
||||||
// 传 nil 指针(**nil)→ detach
|
// 传 nil 指针(**nil)→ detach
|
||||||
// 传值(*RequirementNumber 不是 nil)→ resolve & validate
|
// 传值(*RequirementNumber 不是 nil)→ resolve & validate
|
||||||
reqID := cur.RequirementID
|
reqID := cur.RequirementID
|
||||||
auditFrom := ""
|
|
||||||
auditTo := ""
|
|
||||||
if in.RequirementNumber != nil {
|
if in.RequirementNumber != nil {
|
||||||
auditFrom = "<unchanged>"
|
auditFrom := "<none>"
|
||||||
if cur.RequirementID != nil {
|
if cur.RequirementID != nil {
|
||||||
auditFrom = cur.RequirementID.String()
|
auditFrom = cur.RequirementID.String()
|
||||||
}
|
}
|
||||||
|
var auditTo string
|
||||||
if *in.RequirementNumber == nil {
|
if *in.RequirementNumber == nil {
|
||||||
reqID = nil
|
reqID = nil
|
||||||
auditTo = "<none>"
|
auditTo = "<none>"
|
||||||
@@ -157,18 +159,21 @@ func (s *issueService) Update(ctx context.Context, c Caller, slug string, number
|
|||||||
reqID = &r.ID
|
reqID = &r.ID
|
||||||
auditTo = r.ID.String()
|
auditTo = r.ID.String()
|
||||||
}
|
}
|
||||||
|
if auditFrom != auditTo {
|
||||||
|
changed["from_requirement"] = auditFrom
|
||||||
|
changed["to_requirement"] = auditTo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(changed) == 0 {
|
||||||
|
return cur, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := s.repo.UpdateIssueCore(ctx, cur.ID, title, desc, reqID)
|
out, err := s.repo.UpdateIssueCore(ctx, cur.ID, title, desc, reqID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
meta := map[string]any{"changed_fields": "<various>"}
|
s.recordAudit(ctx, c, "issue.update", out.ID.String(), map[string]any{"changed_fields": changed})
|
||||||
if auditFrom != "" {
|
|
||||||
meta["from_requirement"] = auditFrom
|
|
||||||
meta["to_requirement"] = auditTo
|
|
||||||
}
|
|
||||||
s.recordAudit(ctx, c, "issue.update", out.ID.String(), meta)
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user