|
| 1 | +# Owner overrides |
| 2 | + |
| 3 | +## Context |
| 4 | + |
| 5 | +Today, if more than one mapper claims ownership of a file, we return an error. There are limited exceptions for directory ownership where multiple directories may apply, and we conceptually pick the nearest directory. |
| 6 | + |
| 7 | +We have seen frequent confusion and repeated requests for a way to explicitly override ownership. |
| 8 | + |
| 9 | +## Proposal |
| 10 | + |
| 11 | +Allow overrides, resolving conflicts by choosing the most specific claim. |
| 12 | + |
| 13 | +Priority (most specific to least specific) |
| 14 | +Ownership for a file is determined by the closest applicable claim: |
| 15 | + |
| 16 | +File annotations (inline annotations in the file) |
| 17 | +Directory ownership (the nearest ancestor directory claim). If directory ownership is declared above a package file, it would be lower priority |
| 18 | +Package ownership (package.yml, package.json) |
| 19 | +Team glob patterns |
| 20 | +If multiple teams match at the same priority level (e.g., multiple team glob patterns match the same path), this remains an error. |
| 21 | + |
| 22 | +## Tooling to reduce confusion |
| 23 | + |
| 24 | +Update the for-file command to list all matching teams in descending priority, so users can see which owner would win and why. |
| 25 | + |
| 26 | +### generate-and-validate AND for-file |
| 27 | + |
| 28 | +Both places need to be updated. There should be tests in place that verify consistency. **I can likely compare the src/parser.rs derived team to the for-file team** in tests locally and against a large repo. |
| 29 | + |
| 30 | +## The details |
| 31 | + |
| 32 | +### gv |
| 33 | +- implement the new errors |
| 34 | +- sort a file's "owners" by priority when writing to CODEOWNERS use the most specific...I think this means we can't have redundancy |
| 35 | + |
| 36 | +### for-file |
| 37 | +- same errors? Look for reuse |
| 38 | +- descriptive results |
| 39 | +- gem should have a verbose option |
| 40 | + |
| 41 | +### "New" errors |
| 42 | + |
| 43 | +1. FileWithMultipleOwners is still a thing. Probably only possible if more than one team file claims ownership. Reason being is that other "claims" can be prioritized by proximity to the file |
| 44 | +1. RedundantOwnership. **Looks like redundancy is already OK**. Maybe? Would we want avoid files getting owned by the same team multiple ways? It could potentially not be a problem with a really good `for-file`, but ... It's important to keep in mind that it's better to start more restrictive and then relax constraints than the other way around. |
| 45 | + |
| 46 | +### Questions |
| 47 | +1. Why is owner's source a vec? |
| 48 | +Looks like every claim for the same team goes in there. As an example, you can add a matching file annotation and there will be no error and for-file will show all sources |
0 commit comments