tools/bump: stop commenting when applied areas change

Description already carries the outcome; the comment was noise.
This commit is contained in:
Kristoffer Dalby committed 2026-10-15 10:50:32 +02:00
1 parent a2e4451fcf
commit bf63feb320
3 files changed
+3 -51

No files matched your search

+3 -13
View File
@@ -99,8 +99,7 @@ func publish(ctx context.Context, r *repo, opt publishOptions, results []result)
return err
}
now := markerOf(results, tree, head)
body := renderBody(results, now, opt.Gate)
body := renderBody(results, markerOf(results, tree, head), opt.Gate)
pr, err := lookupPR(ctx, r, opt.Slug, opt.Branch)
if err != nil {
@@ -114,7 +113,7 @@ func publish(ctx context.Context, r *repo, opt publishOptions, results []result)
}
if pr != nil && pr.State == "OPEN" {
return updateOpen(ctx, r, opt, pr, body, now)
return updateOpen(ctx, r, opt, pr, body)
}
if pr != nil && pr.State == "CLOSED" {
@@ -138,7 +137,7 @@ func publish(ctx context.Context, r *repo, opt publishOptions, results []result)
// updateOpen refreshes an existing pull request in place, but refuses to
// force-push over work the bot did not author.
func updateOpen(ctx context.Context, r *repo, opt publishOptions, pr *prState, body string, now marker) error {
func updateOpen(ctx context.Context, r *repo, opt publishOptions, pr *prState, body string) error {
prev, hadMarker := parseMarker(pr.Body)
remoteTip := remoteBranchSHA(ctx, r, opt.Remote, opt.Branch)
@@ -159,15 +158,6 @@ func updateOpen(ctx context.Context, r *repo, opt publishOptions, pr *prState, b
return err
}
// Only speak up when the outcome actually changed. A daily "still the
// same" comment trains the reader to ignore the thread.
if hadMarker && changedAreas(prev, now) {
if _, err := r.run(ctx, "gh", "pr", "comment", strconv.Itoa(pr.Number), "--repo", opt.Slug, //nolint:noinlineerr
"--body", "The set of applied areas changed since the last run; see the updated description."); err != nil {
return err
}
}
log.Printf("updated pull request #%d", pr.Number)
return nil
-16
View File
@@ -191,19 +191,3 @@ func cell(s string) string {
return s
}
// changedAreas reports whether the outcome differs from the last run, which is
// what decides between silently updating the pull request and commenting on it.
func changedAreas(prev marker, now marker) bool {
if len(prev.Areas) != len(now.Areas) {
return true
}
for name, st := range now.Areas {
if prev.Areas[name] != st {
return true
}
}
return false
}
-22
View File
@@ -50,28 +50,6 @@ func TestParseMarkerAbsent(t *testing.T) {
}
}
func TestChangedAreas(t *testing.T) {
base := marker{Areas: map[string]string{"flake": "applied", "gomod": "applied"}}
tests := []struct {
name string
now marker
want bool
}{
{name: "identical", now: marker{Areas: map[string]string{"flake": "applied", "gomod": "applied"}}},
{name: "state changed", now: marker{Areas: map[string]string{"flake": "applied", "gomod": "dropped"}}, want: true},
{name: "area added", now: marker{Areas: map[string]string{"flake": "applied", "gomod": "applied", "generate": "applied"}}, want: true},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if got := changedAreas(base, test.now); got != test.want {
t.Errorf("changedAreas = %v, want %v", got, test.want)
}
})
}
}
// A summary containing a pipe would otherwise split the markdown table.
func TestCellEscapesTableBreakers(t *testing.T) {
got := cell("a | b\nc")