fix(filter_repos): match full repo paths and normalize trailing slashes#539
Draft
fix(filter_repos): match full repo paths and normalize trailing slashes#539
Conversation
why: filter_repos() only compares r["path"].parent against the path pattern, so full repo paths (e.g. from zsh glob expansion of tanstack-*) and workspace roots with trailing slashes never match — discoverable via discover but not via sync. what: - add test_filter_dir_exact_repo_path (xfail): full repo path like /home/me/myproject/github_projects/kaptan should filter to that repo - add test_filter_dir_workspace_root_trailing_slash (xfail): workspace root with trailing slash should match all repos under it
why: vcspull sync ~/study/typescript/tanstack-* passes zsh-expanded absolute paths like /home/d/study/typescript/tanstack-router; filter_repos only matched against r["path"].parent (/home/d/study/typescript), so the full path never matched. Tilde-prefixed paths and workspace roots with trailing slashes also failed silently. what: - also match fnmatch against r["path"] (full repo path) in addition to parent - expand ~ and $HOME in pattern before comparing against absolute stored paths - normalize trailing slash via pathlib.Path so /foo/bar/ matches parent /foo/bar
…ing fixed why: filter_repos now matches against both r["path"].parent and r["path"], and normalizes trailing slashes, so the regression tests pass unconditionally. what: - remove @pytest.mark.xfail from test_filter_dir_exact_repo_path - remove @pytest.mark.xfail from test_filter_dir_workspace_root_trailing_slash - remove unused pytest import
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
filter_repos()so that passing a full repo path (e.g./home/d/study/typescript/tanstack-router, as produced by shell glob expansion) correctly matches the configured repository — previously only the parent directory was matched against the pattern, so exact repo paths never resolved.~/study/typescript/) silently returning no results due to the slash surviving into thefnmatchcomparison against the normalized stored path.$HOMEpatterns (e.g.~/study/typescript/tanstack-router) not matching stored absolute paths by expanding them via the existingexpand_dir()before comparison.Root cause
filter_repos()compared onlypathlib.Path(r["path"]).parentagainst the pattern — designed for wildcard workspace patterns like*github_projects*. This broke when the shell expanded a glob such as~/study/typescript/tanstack-*into a list of absolute repo paths before handing them to vcspull:discoverfound those repos in config via dict-key lookup, butsynccould not.Changes
src/vcspull/config.py—filter_repos()path block:pathlib.Pathto strip trailing slashes~/$HOMEviaexpand_dir()when present, so tilde patterns match stored absolute pathsfnmatchwith a new full-pathfnmatch, making exact repo paths resolve without breaking any existing wildcard behaviorDesign decisions
OR semantics, not replacement: matching against both
r["path"].parent(existing) andr["path"](new) is strictly additive — it can only produce more matches. All existing wildcard tests continue to pass unchanged.Reuse
expand_dir(): already defined in the same module withexpandvars+expandusersemantics; no duplication needed.Test plan
test_filter_dir_exact_repo_path— full absolute repo path resolves to the correct entrytest_filter_dir_workspace_root_trailing_slash— workspace root with trailing slash resolves all repos under ittest_filter_dir— existing wildcard pattern (*github_project*) still passesuv run ruff check . --fix --show-fixes— no lint errorsuv run ruff format .— no formatting changesuv run mypy— no type errorsuv run py.test --reruns 0— full suite passes