Validate /path
entries are valid paths in repository
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
Currently, CODEOWNERS patterns are not validated against the repository's actual files. This means users can add patterns that don't match any files, leading to potential confusion or mistakes in code ownership rules i.e:
/specific/file_does_not_exist.rb @ruby-devs # should show a INVALID_PATH error
/specific/file_exists.rb @ruby-devs # should be fine
Proposal
Add validation to check if CODEOWNERS patterns match any files in the repository's default branch. If it does not, return Error::INVALID_PATH
. This error will also need to be created. We can account for exact paths, directory paths and wildcard parts.
Considerations
- Need to be able to retrieve all repository files and some repositories may be large. Cached versions? Via Gitaly RPC?
- Wildcard pattern matching is expensive so need to consider this and how it impacts the parsing performance of CODEOWNERS file
- Exact path matches should be pretty quick
- We can validate against default branch
- Ideally a spike to explore will be great
Edited by 🤖 GitLab Bot 🤖