Consider new, untracked team config files during validate/generate#113
Open
dduugg wants to merge 1 commit into
Open
Consider new, untracked team config files during validate/generate#113dduugg wants to merge 1 commit into
dduugg wants to merge 1 commit into
Conversation
rubyatscale/code_ownership#149: adding a new team was silently ignored until the new team.yml was `git add`-ed. The project walk deliberately excludes untracked files (codeowners-rs#46/#74/#76 - so a developer can keep scratch files around locally without validate forcing them to assign an owner), but that exclusion also covered team config files, which define real ownership rules the moment they exist rather than being scratch work anyone would leave uncommitted on purpose. Exempt files matching `team_file_glob` from the tracked-files check specifically, leaving ordinary source files subject to it as before. Reproduced the exact bug against a real build first (a new team owning an already-tracked file, e.g. README.md, was reported unowned because the team file disappeared from the walk while README.md - already committed - did not), confirmed a fix, then found and preserved a directly conflicting existing test (test_skip_untracked_files) that relies on the untracked-scratch-file behavior on purpose, which a first, broader attempt at this fix would have silently regressed. Added two tests: one reproducing #149 end to end (new untracked team + existing tracked file -> validate succeeds), and one pinning that an untracked *source* file (non-team) is still correctly ignored, so the scoped nature of this fix doesn't regress by accident later. Verified: full `cargo test` suite (all 83+ tests, including the pre-existing test_skip_untracked_files), cargo clippy --all-targets, and cargo fmt --check all clean.
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.
Summary
Fixes rubyatscale/code_ownership#149 ("New teams aren't considered in validate of CLI calls").
Adding a new team was silently ignored until the new
team.ymlwasgit add-ed. The project walk deliberately excludes untracked files (#46/#74/#76 — so a developer can keep scratch files around locally withoutvalidateforcing them to assign an owner), but that exclusion also covered team config files, which define real ownership rules the moment they exist rather than being scratch work anyone would leave uncommitted on purpose.Root cause, reproduced against a real build before touching any code:
tracked_files::find_tracked_filesrunsgit ls-files(staged/committed files only) andProjectBuilder'sWalkBuilder::filter_entrydrops any file not in that set. When a new team file is added without staging it, it's invisible to the walk — so the team never gets loaded, and any already-tracked file that should newly become owned by it (e.g. an existingREADME.md) is reported as unowned instead. (Making the owned file new/untracked too, rather than already-tracked, masks the bug entirely — neither file is visible, so no mismatch is ever observed. That's why an early, broader version of this fix looked right in isolation but wasn't actually testing the reported scenario.)Fix: exempt files matching
team_file_globfrom the tracked-files check specifically. Ordinary source files remain subject to it, unchanged.I initially considered a broader fix (stop excluding any untracked-but-not-gitignored file), but
cargo testcaught that it directly regressestest_skip_untracked_files— an existing, intentional test from #74/#76 for exactly the scratch-file use case #46 describes. That's a real, legitimate use case I don't want to break, so this PR scopes the fix to team files only, per that discussion.Test plan
tests/untracked_new_file_test.rs— reproduces #149 end to end (new untracked team + existing tracked file → validate succeeds)tests/untracked_source_file_test.rs— pins that an untracked source file (non-team) is still correctly ignored, so this fix can't silently broaden latercargo test(all 83+ unit tests + every integration test file, including the pre-existingtest_skip_untracked_files),cargo clippy --all-targets, andcargo fmt --checkall clean