From ca9d042745a4bf8c716b825126f5b65f5fc3f778 Mon Sep 17 00:00:00 2001 From: Ben Judd Date: Mon, 9 Feb 2026 11:37:47 -0500 Subject: [PATCH] Add option to suppress unowned file warning. --- README.md | 4 ++++ internal/app/app.go | 6 ++++-- internal/config/config.go | 1 + internal/config/config_test.go | 21 +++++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f4bd664..23f3aab 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,10 @@ disable_smart_dismissal = true # This is useful for ownership handoffs where both the outgoing and incoming teams must review require_both_branch_reviewers = false +# `suppress_unowned_warning` (default false) suppresses the warning messages about unowned files +# Useful when you intentionally have files without codeowners +suppress_unowned_warning = true + # `enforcement` allows you to specify how the Codeowners Plus check should be enforced [enforcement] # see "Enforcement Options" below for more details diff --git a/internal/app/app.go b/internal/app/app.go index a290cda..c95fbd4 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -170,8 +170,10 @@ func (a *App) Run() (*OutputData, error) { codeOwners.SetAuthor(author) // Warn about unowned files - for _, uFile := range codeOwners.UnownedFiles() { - a.printWarn("WARNING: Unowned File: %s\n", uFile) + if !conf.SuppressUnownedWarning { + for _, uFile := range codeOwners.UnownedFiles() { + a.printWarn("WARNING: Unowned File: %s\n", uFile) + } } // Print file owners if verbose diff --git a/internal/config/config.go b/internal/config/config.go index 046366b..b089b91 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -18,6 +18,7 @@ type Config struct { DetailedReviewers bool `toml:"detailed_reviewers"` DisableSmartDismissal bool `toml:"disable_smart_dismissal"` RequireBothBranchReviewers bool `toml:"require_both_branch_reviewers"` + SuppressUnownedWarning bool `toml:"suppress_unowned_warning"` } type Enforcement struct { diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 7f9cd9d..176b450 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -89,6 +89,23 @@ max_reviews = 2 }, expectedErr: false, }, + { + name: "config with suppress_unowned_warning enabled", + configContent: ` +suppress_unowned_warning = true +`, + path: "testdata/", + expected: &Config{ + MaxReviews: nil, + MinReviews: nil, + UnskippableReviewers: []string{}, + Ignore: []string{}, + Enforcement: &Enforcement{Approval: false, FailCheck: true}, + HighPriorityLabels: []string{}, + SuppressUnownedWarning: true, + }, + expectedErr: false, + }, { name: "invalid toml", configContent: ` @@ -171,6 +188,10 @@ max_reviews = invalid t.Errorf("RequireBothBranchReviewers: expected %v, got %v", tc.expected.RequireBothBranchReviewers, got.RequireBothBranchReviewers) } + if got.SuppressUnownedWarning != tc.expected.SuppressUnownedWarning { + t.Errorf("SuppressUnownedWarning: expected %v, got %v", tc.expected.SuppressUnownedWarning, got.SuppressUnownedWarning) + } + if tc.expected.Enforcement != nil { if got.Enforcement == nil { t.Error("expected Enforcement to be set")