Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/vcspull/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,17 @@ def filter_repos(
repo_list: list[ConfigDict] = []

if path:
path_str = str(path)
if "~" in path_str or "$" in path_str:
path_str = str(expand_dir(pathlib.Path(path_str)))
else:
path_str = str(pathlib.Path(path_str))
repo_list.extend(
[
r
for r in config
if fnmatch.fnmatch(str(pathlib.Path(r["path"]).parent), str(path))
if fnmatch.fnmatch(str(pathlib.Path(r["path"]).parent), path_str)
or fnmatch.fnmatch(str(r["path"]), path_str)
],
)

Expand Down
20 changes: 20 additions & 0 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ def test_filter_dir() -> None:
assert r["name"] == "kaptan"


def test_filter_dir_exact_repo_path() -> None:
"""`filter_repos` filter by exact full repo path (e.g. after zsh glob expansion)."""
repo_list = filter_repos(
fixtures.config_dict_expanded,
path="/home/me/myproject/github_projects/kaptan",
)
assert len(repo_list) == 1
assert repo_list[0]["name"] == "kaptan"


def test_filter_dir_workspace_root_trailing_slash() -> None:
"""`filter_repos` filter by workspace root path with trailing slash."""
repo_list = filter_repos(
fixtures.config_dict_expanded,
path="/home/me/myproject/github_projects/",
)
assert len(repo_list) == 1
assert repo_list[0]["name"] == "kaptan"


def test_filter_name() -> None:
"""`filter_repos` filter by name."""
repo_list = filter_repos(fixtures.config_dict_expanded, name=".vim")
Expand Down
Loading