-
Notifications
You must be signed in to change notification settings - Fork 18
chore: show line diff count #1042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -150,6 +150,27 @@ type aggregate struct { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Unsupported int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Changed int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Unchanged int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Additions int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deletions int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func countDiffLines(current, proposed string) (int, int) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a := difflib.SplitLines(current) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| b := difflib.SplitLines(proposed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| m := difflib.NewMatcher(a, b) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var adds, dels int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for _, op := range m.GetOpCodes() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch op.Tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case 'r': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dels += op.I2 - op.I1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| adds += op.J2 - op.J1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case 'd': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dels += op.I2 - op.I1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case 'i': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| adds += op.J2 - op.J1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return adds, dels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func aggregateResults(results []agentResult) aggregate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -166,6 +187,10 @@ func aggregateResults(results []agentResult) aggregate { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if r.HasChanges != nil && *r.HasChanges { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a.Changed++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| adds, dels := countDiffLines(r.Current, r.Proposed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a.Additions += adds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a.Deletions += dels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if r.HasChanges != nil && !*r.HasChanges { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a.Unchanged++ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -228,25 +253,12 @@ func (a aggregate) checkTitle() string { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if a.Total > 0 && a.Unsupported == a.Total { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "All agents unsupported" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| diffSummary := fmt.Sprintf("+%d -%d", a.Additions, a.Deletions) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if a.Errored > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "%d errored, %d changed, %d unchanged, %d unsupported", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a.Errored, a.Changed, a.Unchanged, a.Unsupported, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Sprintf("%s (%d errored)", diffSummary, a.Errored) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if a.Changed > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "%d changed, %d unchanged, %d unsupported", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a.Changed, a.Unchanged, a.Unsupported, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if a.Unsupported > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return fmt.Sprintf( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "No changes (%d unsupported)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| a.Unsupported, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "No changes" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return diffSummary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+256
to
+261
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UX: "+0 -0" replaces the old "No changes" summary. When every agent reports Optional fallback diffSummary := fmt.Sprintf("+%d -%d", a.Additions, a.Deletions)
if a.Errored > 0 {
return fmt.Sprintf("%s (%d errored)", diffSummary, a.Errored)
}
+ if a.Additions == 0 && a.Deletions == 0 && a.Changed == 0 {
+ return "No changes"
+ }
return diffSummary📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // formatAgentSection renders the markdown block for one agent in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New behavior aggregates
Additions/Deletionsbased on diffs, but the tests currently only assert the final title string and do not verify thataggregateResultscomputesAdditions/Deletionscorrectly across multiple agents / multi-line changes. Add a focused unit test (and/or tests forcountDiffLines) that asserts expected additions/deletions counts for representative diffs and ensures unchanged/unsupported/errored agents don’t affect the totals.