mirror of
https://github.com/juanfont/headscale.git
synced 2026-10-23 06:46:49 +09:00
tools/bump: stop commenting when applied areas change
Description already carries the outcome; the comment was noise.
This commit is contained in:
1 parent
a2e4451fcf
commit
bf63feb320
3 files changed
+3
-51
No files matched your search
+3
-13
@@ -99,8 +99,7 @@ func publish(ctx context.Context, r *repo, opt publishOptions, results []result)
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
now := markerOf(results, tree, head)
|
body := renderBody(results, markerOf(results, tree, head), opt.Gate)
|
||||||
body := renderBody(results, now, opt.Gate)
|
|
||||||
|
|
||||||
pr, err := lookupPR(ctx, r, opt.Slug, opt.Branch)
|
pr, err := lookupPR(ctx, r, opt.Slug, opt.Branch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -114,7 +113,7 @@ func publish(ctx context.Context, r *repo, opt publishOptions, results []result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if pr != nil && pr.State == "OPEN" {
|
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" {
|
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
|
// updateOpen refreshes an existing pull request in place, but refuses to
|
||||||
// force-push over work the bot did not author.
|
// 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)
|
prev, hadMarker := parseMarker(pr.Body)
|
||||||
|
|
||||||
remoteTip := remoteBranchSHA(ctx, r, opt.Remote, opt.Branch)
|
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
|
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)
|
log.Printf("updated pull request #%d", pr.Number)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -191,19 +191,3 @@ func cell(s string) string {
|
|||||||
|
|
||||||
return s
|
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
|
|
||||||
}
|
|
||||||
@@ -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.
|
// A summary containing a pipe would otherwise split the markdown table.
|
||||||
func TestCellEscapesTableBreakers(t *testing.T) {
|
func TestCellEscapesTableBreakers(t *testing.T) {
|
||||||
got := cell("a | b\nc")
|
got := cell("a | b\nc")
|
||||||
|
|||||||
Reference in new issue
Block a user