Exempt specific files from Codeowners rules
What does this MR do and why?
Problem
Currently there is no way to exempt specific files from requiring code owner approval.
Solution
This adds support for exclusion patterns in CODEOWNERS using the '!' prefix:
* @default-owner # All files require approval
!pom.xml # Except pom.xml which needs no approval
Approach
Given that entries_for_path
is where we determine file ownership, we modified Gitlab::Codeowners::Entry
to support exclusion patterns by adding an exclusion flag(!). When processing CODEOWNERS patterns in order, patterns starting with !
are marked as exclusions. So during path matching in entries_for_path
, if any matching entry is an exclusion, that file is excluded from requiring ownership approval for that section.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Related to #41914 (closed)