Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 21 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: `
Expand Down Expand Up @@ -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")
Expand Down
Loading