Repository navigation
Fix package ownership for nested packages and for package.yml with package.json - #156
Merged
Merged
Conversation
`validate` built a matcher for only the outermost of a set of nested packages of one type, so a file in a nested package got the outer package's team. CODEOWNERS and `for-file` give it the nested package's team. A full `validate` didn't notice, but `validate <files>` compares each file's owner with CODEOWNERS, so it failed with "CODEOWNERS out of date", which regenerating can't fix. A package at the project root encloses every other package, so with one, every file in another package failed this way. Each package's matcher now leaves out the packages of its type nested in it, so a file matches only its nearest package. A package naming a team that doesn't exist still gets no matcher, so its files still fall through to the enclosing package, as in CODEOWNERS and `for-file`. A file in a nested package that another source gives the outer package's team, such as an annotation, now has two owners in `validate`, as it already did in `for-file`.
…json `for-file` stopped at the first package it found in the nearest directory with one, checking `package.yml` before `package.json`. In a directory with both, naming different teams, it gave the `package.yml`'s team, while `validate` matches both and reports the file as having two owners. It now returns both, so `for-file` reports the conflict that `validate` does, and lists both files when they name one team. code_ownership's `for_file` takes the first owner, which is now the first by team name, as for any other tie.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while scoping #69. Both are bugs in today's behavior, independent of the precedence discussion there.
What
validate, a file in a nested package now belongs to the nearest package of its type, as it already does in CODEOWNERS andfor-file.for-filenow reports both packages when one directory has apackage.ymland apackage.json, asvalidatealready does.Why
Nested packages. The package mappers built a matcher only for the outermost of a set of nested packages, so
validategave a file in a nested package the outer package's team. CODEOWNERS andfor-filegive it the nested package's team. A fullvalidatedidn't notice. Butvalidate <files>compares each file's owner with CODEOWNERS, so it failed with "CODEOWNERS out of date", which regenerating can't fix. A package at the project root encloses every other package, so with one, every file in another package failed this way.A
package.ymland apackage.jsonin one directory.for-filestopped at the first package it found, checkingpackage.ymlfirst. When the two named different teams, it answered with thepackage.yml's team, whilevalidatereported two owners.How
PackageMapper::owner_matchersgives each package's matcher the directories of the packages of its type nested directly in it as subtracted globs. Sorting the packages by root puts a package's descendants right after it, so this is one pass.remove_nested_packagesis gone.for-file.nearest_package_ownersreturns every package in the nearest directory that has one naming a known team.Behavior change
.codeowner, now has two owners invalidate.for-filealready reported it that way, sovalidatecan newly fail on such a file.for-filenow fails with "file is owned by multiple teams". code_ownership'sfor_filetakes the first owner, which is now the first by team name, as for any other tie, rather than thepackage.yml's team.Out of scope
A package of one type nested in a package of the other, such as a
package.jsoninside apackage.ymldirectory, still givesvalidatetwo owners, whilefor-filepicks the nearer one and CODEOWNERS always picks thepackage.json. Choosing one answer for that is part of the precedence proposal in #69.Tests
tests/package_ownership_test.rs. Each test fails onmain:validate <files>passes, andfor-filewith and without--from-codeownersgives each file the nearer package.validate <files>passes.validatereports two owners, asfor-filedoes.package.ymland apackage.jsonnaming different teams:for-filereports both, asvalidatedoes.nearest_package_ownersreturns both package files in one directory. The tworemove_nested_packagestests are removed, and the root package test now expects the nested package to be left out.cargo test(341 passed, 3 ignored),cargo clippy --all-targets --all-features -- -D warningsandcargo fmt --all -- --check.