mszostok / codeowners-validator

The GitHub CODEOWNERS file validator
Apache License 2.0
211 stars 48 forks source link

Add support for specifically excluding code owners on files and subfolders #177

Open dusi opened 1 year ago

dusi commented 1 year ago

Description

Based on GitHub's documentation it should be possible to exclude certain folders (subfolders) from having an owner.

# In this example, @octocat owns any file in the `/apps`
# directory in the root of your repository except for the `/apps/github`
# subdirectory, as its owners are left empty.
/apps/ @octocat
/apps/github
            ^^^ has no owner = will not require sign off on PRs

Now this is something that's not possible with codeowners-validator and I wonder if adding this would help in situations where you want to make exceptions for specific files or subfolders.

Reasons

Adding support for this would not only support GitHub's CODEOWNERS's specs but it would allow adding exceptions to certain subfolders or files that don't need to be signed-off on. An example could be auto-generated code or documentation within a module.

Example A - Exclude generated code from requiring sign-offs on PRs

.
└── ModuleA
    └── Implementation
        └── Foo.swift
    └── Generated
        └── Bar.swift

Then CODEOWNERS would exclude /ModuleA/Generated from code ownership

/ModuleA @userA
/ModuleA/Generated
                  ^^^ not owned by anyone (deliberate exception)

Example B - Exclude documentation from requiring sign-offs on PRs

.
└── ModuleB
    └── Implementation
        └── Foo.swift
    └── README.md

Then CODEOWNERS would exclude README.md from code ownership

/ModuleB @userB
/ModuleB/README.md
                  ^^^ not owned by anyone
TansyArron commented 1 year ago

Just bumping this up, as I've just run into this issue. While I'm not enthusiastic about githubs choice of syntax for excludes, I do think tools like this validator should support the documented usage.