fix(federation): skip federated subrepos on Windows (path normalization)#78
Merged
Conversation
is_under_any resolved the subrepo roots but left an already-absolute candidate path untouched, and compared with pathlib's case-sensitive relative_to. On Windows the filesystem is case-insensitive and resolve() can change casing or 8.3 short-names, so every federated subrepo failed to match and none of its files were skipped: cgh init counted, and cgh index scanned, the whole tree including federated subdirs. Now both sides are resolved and os.path.normcase'd, with a separator-boundary prefix check (so /foo/services-bar is not treated as under /foo/services). This fixes the file census and the actual parent scan, which both route through is_under_any. POSIX behavior is unchanged (normcase is identity). Tests: nested-subrepo match (the landing-zone edf-sa/services-* layout), sibling-prefix boundary safety, root-itself, on top of the existing cases.
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.
The bug
On Windows,
cgh initcounts (andcgh indexscans) the entire tree including federated subrepos, instead of skipping them. Reported on a landing-zone monorepo with 18 federated service subrepos underedf-sa/(2232 files, mostly inside the subrepos).Root cause
is_under_anyresolved the subrepo roots (viaresolve_children) but left an already-absolute candidate path untouched, then compared with pathlib's case-sensitiverelative_to. Windows is case-insensitive andresolve()can change casing / 8.3 short-names, so the prefix never matched -> every subrepo missed the skip list. POSIX was unaffected (resolve of an absolute path is a no-op there), which is why it only showed up on Git Bash / Windows.Fix
Resolve both sides and compare
os.path.normcase'd strings on a path-separator boundary (so/foo/services-baris not treated as under/foo/services). Both the file census and the real scan route throughis_under_any, so this fixes both.Tests
nested-subrepo match (the
edf-sa/services-*layout), sibling-prefix boundary safety, root-itself, plus the existing cases. Server/indexer/cli suites: 155 passed.