diff --git a/bot/internal/bot/label.go b/bot/internal/bot/label.go index 855d62fe..444c4631 100644 --- a/bot/internal/bot/label.go +++ b/bot/internal/bot/label.go @@ -66,6 +66,11 @@ func (b *Bot) labels(ctx context.Context, files []github.PullRequestFile) ([]str labels = append(labels, string(prSize(files))) } + if !requiresChangelog(files) { + log.Println("Label: Adding no-changelog.") + labels = append(labels, "no-changelog") + } + // The branch name is unsafe, but here we are simply adding a label. if b.c.Environment.Repository != env.CloudRepo && isReleaseBranch(b.c.Environment.UnsafeBase) { log.Println("Label: Found backport branch.") @@ -102,6 +107,17 @@ func deduplicate(s []string) []string { return out } +// requiresChangelog indicates whether, based on the files in a pull request, +// the PR should have the "no-changelog" label. +func requiresChangelog(files []github.PullRequestFile) bool { + for _, f := range files { + if !strings.HasPrefix(f.Name, "docs/") { + return true + } + } + return false +} + var prefixes = map[string]map[string][]string{ env.TeleportRepo: { "bpf/": {"bpf"}, diff --git a/bot/internal/bot/label_test.go b/bot/internal/bot/label_test.go index fe673913..80f0a970 100644 --- a/bot/internal/bot/label_test.go +++ b/bot/internal/bot/label_test.go @@ -56,7 +56,7 @@ func TestLabel(t *testing.T) { Deletions: 10, }, }, - labels: []string{"documentation", string(small)}, + labels: []string{"documentation", "no-changelog", string(small)}, }, { desc: "helm", @@ -91,7 +91,7 @@ func TestLabel(t *testing.T) { Deletions: 1000, }, }, - labels: []string{"backport", "documentation", string(xlarge)}, + labels: []string{"backport", "documentation", "no-changelog", string(xlarge)}, }, { desc: "web only",