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
|
||||
if in.Title != nil {
|
||||
changed := map[string]any{}
|
||||
if in.Title != nil && *in.Title != cur.Title {
|
||||
title = *in.Title
|
||||
changed["title"] = "<changed>"
|
||||
}
|
||||
if in.Description != nil {
|
||||
if in.Description != nil && *in.Description != cur.Description {
|
||||
desc = *in.Description
|
||||
changed["description"] = "<changed>"
|
||||
}
|
||||
|
||||
// requirement 三态:未传(in.RequirementNumber == nil)→ 保持
|
||||
// 传 nil 指针(**nil)→ detach
|
||||
// 传值(*RequirementNumber 不是 nil)→ resolve & validate
|
||||
reqID := cur.RequirementID
|
||||
auditFrom := ""
|
||||
auditTo := ""
|
||||
if in.RequirementNumber != nil {
|
||||
auditFrom = "<unchanged>"
|
||||
auditFrom := "<none>"
|
||||
if cur.RequirementID != nil {
|
||||
auditFrom = cur.RequirementID.String()
|
||||
}
|
||||
var auditTo string
|
||||
if *in.RequirementNumber == nil {
|
||||
reqID = nil
|
||||
auditTo = "<none>"
|
||||
@@ -157,18 +159,21 @@ func (s *issueService) Update(ctx context.Context, c Caller, slug string, number
|
||||
reqID = &r.ID
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
meta := map[string]any{"changed_fields": "<various>"}
|
||||
if auditFrom != "" {
|
||||
meta["from_requirement"] = auditFrom
|
||||
meta["to_requirement"] = auditTo
|
||||
}
|
||||
s.recordAudit(ctx, c, "issue.update", out.ID.String(), meta)
|
||||
s.recordAudit(ctx, c, "issue.update", out.ID.String(), map[string]any{"changed_fields": changed})
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user