Skip to content

docs(CHANGES): libvcs v0.27.0 (linting updates) #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force

<!-- Maintainers, insert changes / features for the next release here -->

### Breaking changes

- libvcs: v0.25.0 -> v0.26.0 (#434)

Renamings of `dir` to `path`.

- Fix shadowing of python builtins

- `dir` -> `path` (#434)

### Documentation

- Refactor API docs to split across multiple pages (#431)
Expand Down
11 changes: 7 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ def cwd_default(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path) -> None
monkeypatch.chdir(tmp_path)


@pytest.fixture(autouse=True, scope="session")
@pytest.mark.usefixtures("set_home")
def xdg_config_path(user_path: pathlib.Path) -> pathlib.Path:
@pytest.fixture(autouse=True)
def xdg_config_path(
user_path: pathlib.Path,
set_home: pathlib.Path,
) -> pathlib.Path:
"""Create and return path to use for XDG Config Path."""
p = user_path / ".config"
p.mkdir()
if not p.exists():
p.mkdir()
return p


Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ vcspull = 'vcspull:cli.cli'

[tool.poetry.dependencies]
python = "^3.9"
libvcs = "~0.26.0"
libvcs = "~0.27.0"
colorama = ">=0.3.9"
PyYAML = "^6.0"

Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

config[path][reponame] = {
"name": reponame,
"dir": path / reponame,
"path": path / reponame,
"url": f"git+ssh://{url_to_repo}",
"remotes": {
"origin": GitRemote(
Expand Down
8 changes: 4 additions & 4 deletions src/vcspull/cli/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ def sync(
found_repos = []

for repo_pattern in repo_patterns:
dir, vcs_url, name = None, None, None
path, vcs_url, name = None, None, None
if any(repo_pattern.startswith(n) for n in ["./", "/", "~", "$HOME"]):
dir = repo_pattern
path = repo_pattern
elif any(repo_pattern.startswith(n) for n in ["http", "git", "svn", "hg"]):
vcs_url = repo_pattern
else:
name = repo_pattern

# collect the repos from the config files
found = filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name)
found = filter_repos(configs, path=path, vcs_url=vcs_url, name=name)
if len(found) == 0:
print(NO_REPOS_FOR_TERM_MSG.format(name=name))
found_repos.extend(filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name))
found_repos.extend(filter_repos(configs, path=path, vcs_url=vcs_url, name=name))

for repo in found_repos:
try:
Expand Down
18 changes: 9 additions & 9 deletions src/vcspull/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def extract_repos(
if "name" not in conf:
conf["name"] = repo

if "dir" not in conf:
conf["dir"] = expand_dir(
if "path" not in conf:
conf["path"] = expand_dir(
pathlib.Path(expand_dir(pathlib.Path(directory), cwd=cwd))
/ conf["name"],
cwd,
Expand Down Expand Up @@ -301,10 +301,10 @@ def detect_duplicate_repos(
dupes: list[ConfigDictTuple] = []

repo_dirs = {
pathlib.Path(repo["dir"]).parent / repo["name"]: repo for repo in config1
pathlib.Path(repo["path"]).parent / repo["name"]: repo for repo in config1
}
repo_dirs_2 = {
pathlib.Path(repo["dir"]).parent / repo["name"]: repo for repo in config2
pathlib.Path(repo["path"]).parent / repo["name"]: repo for repo in config2
}

for repo_dir, repo in repo_dirs.items():
Expand Down Expand Up @@ -347,19 +347,19 @@ def in_dir(

def filter_repos(
config: list["ConfigDict"],
dir: t.Union[pathlib.Path, t.Literal["*"], str, None] = None,
path: t.Union[pathlib.Path, t.Literal["*"], str, None] = None,
vcs_url: t.Union[str, None] = None,
name: t.Union[str, None] = None,
) -> list["ConfigDict"]:
"""Return a :py:obj:`list` list of repos from (expanded) config file.

dir, vcs_url and name all support fnmatch.
path, vcs_url and name all support fnmatch.

Parameters
----------
config : dict
the expanded repo config in :py:class:`dict` format.
dir : str, Optional
path : str, Optional
directory of checkout location, fnmatch pattern supported
vcs_url : str, Optional
url of vcs remote, fn match pattern supported
Expand All @@ -373,12 +373,12 @@ def filter_repos(
"""
repo_list: list["ConfigDict"] = []

if dir:
if path:
repo_list.extend(
[
r
for r in config
if fnmatch.fnmatch(str(pathlib.Path(r["dir"]).parent), str(dir))
if fnmatch.fnmatch(str(pathlib.Path(r["path"]).parent), str(path))
]
)

Expand Down
4 changes: 2 additions & 2 deletions src/vcspull/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RawConfigDict(t.TypedDict):

vcs: VCSLiteral
name: str
dir: StrPath
path: StrPath
url: str
remotes: GitSyncRemoteDict

Expand All @@ -26,7 +26,7 @@ class ConfigDict(TypedDict):

vcs: t.Optional[VCSLiteral]
name: str
dir: pathlib.Path
path: pathlib.Path
url: str
remotes: NotRequired[t.Optional[GitSyncRemoteDict]]
shell_command_after: NotRequired[t.Optional[list[str]]]
Expand Down
14 changes: 7 additions & 7 deletions tests/fixtures/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,32 @@
{
"vcs": "git",
"name": "linux",
"dir": pathlib.Path("/home/me/myproject/study/linux"),
"path": pathlib.Path("/home/me/myproject/study/linux"),
"url": "git+git://git.kernel.org/linux/torvalds/linux.git",
},
{
"vcs": "git",
"name": "freebsd",
"dir": pathlib.Path("/home/me/myproject/study/freebsd"),
"path": pathlib.Path("/home/me/myproject/study/freebsd"),
"url": "git+https://github.com/freebsd/freebsd.git",
},
{
"vcs": "git",
"name": "sphinx",
"dir": pathlib.Path("/home/me/myproject/study/sphinx"),
"path": pathlib.Path("/home/me/myproject/study/sphinx"),
"url": "hg+https://bitbucket.org/birkenfeld/sphinx",
},
{
"vcs": "git",
"name": "docutils",
"dir": pathlib.Path("/home/me/myproject/study/docutils"),
"path": pathlib.Path("/home/me/myproject/study/docutils"),
"url": "svn+http://svn.code.sf.net/p/docutils/code/trunk",
},
{
"vcs": "git",
"name": "kaptan",
"url": "[email protected]:tony/kaptan.git",
"dir": pathlib.Path("/home/me/myproject/github_projects/kaptan"),
"path": pathlib.Path("/home/me/myproject/github_projects/kaptan"),
"remotes": {
"upstream": GitRemote(
**{
Expand All @@ -87,14 +87,14 @@
{
"vcs": "git",
"name": ".vim",
"dir": pathlib.Path("/home/me/myproject/.vim"),
"path": pathlib.Path("/home/me/myproject/.vim"),
"url": "[email protected]:tony/vim-config.git",
"shell_command_after": ["ln -sf /home/me/.vim/.vimrc /home/me/.vimrc"],
},
{
"vcs": "git",
"name": ".tmux",
"dir": pathlib.Path("/home/me/myproject/.tmux"),
"path": pathlib.Path("/home/me/myproject/.tmux"),
"url": "[email protected]:tony/tmux-config.git",
"shell_command_after": ["ln -sf /home/me/.tmux/.tmux.conf /home/me/.tmux.conf"],
},
Expand Down
14 changes: 7 additions & 7 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def test_sync_cli_filter_non_existent(
config = {
"~/github_projects/": {
"my_git_project": {
"url": f"git+file://{git_repo.dir}",
"remotes": {"test_remote": f"git+file://{git_repo.dir}"},
"url": f"git+file://{git_repo.path}",
"remotes": {"test_remote": f"git+file://{git_repo.path}"},
},
}
}
Expand Down Expand Up @@ -219,11 +219,11 @@ def test_sync(
config = {
"~/github_projects/": {
"my_git_repo": {
"url": f"git+file://{git_repo.dir}",
"remotes": {"test_remote": f"git+file://{git_repo.dir}"},
"url": f"git+file://{git_repo.path}",
"remotes": {"test_remote": f"git+file://{git_repo.path}"},
},
"broken_repo": {
"url": f"git+file://{git_repo.dir}",
"url": f"git+file://{git_repo.path}",
"remotes": {"test_remote": "git+file://non-existent-remote"},
},
}
Expand Down Expand Up @@ -360,8 +360,8 @@ def test_sync_broken(
config = {
"~/github_projects/": {
"my_git_repo": {
"url": f"git+file://{git_repo.dir}",
"remotes": {"test_remote": f"git+file://{git_repo.dir}"},
"url": f"git+file://{git_repo.path}",
"remotes": {"test_remote": f"git+file://{git_repo.path}"},
},
"my_git_repo_not_found": {
"url": "git+file:///dev/null",
Expand Down
22 changes: 11 additions & 11 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LoadYAMLFn(t.Protocol):
def __call__(
self,
content: str,
dir: str = "randomdir",
path: str = "randomdir",
filename: str = "randomfilename.yaml",
) -> tuple[pathlib.Path, list[t.Union[t.Any, pathlib.Path]], list["ConfigDict"]]:
"""Callable function type signature for load_yaml pytest fixture."""
Expand All @@ -28,10 +28,10 @@ def load_yaml(tmp_path: pathlib.Path) -> LoadYAMLFn:
"""Return a yaml loading function that uses temporary directory path."""

def fn(
content: str, dir: str = "randomdir", filename: str = "randomfilename.yaml"
content: str, path: str = "randomdir", filename: str = "randomfilename.yaml"
) -> tuple[pathlib.Path, list[pathlib.Path], list["ConfigDict"]]:
"""Return vcspull configurations and write out config to temp directory."""
_dir = tmp_path / dir
_dir = tmp_path / path
_dir.mkdir()
_config = _dir / filename
_config.write_text(content, encoding="utf-8")
Expand All @@ -45,7 +45,7 @@ def fn(

def test_simple_format(load_yaml: LoadYAMLFn) -> None:
"""Test simple configuration YAML file for vcspull."""
dir, _, repos = load_yaml(
path, _, repos = load_yaml(
"""
vcspull:
libvcs: git+https://github.com/vcs-python/libvcs
Expand All @@ -55,24 +55,24 @@ def test_simple_format(load_yaml: LoadYAMLFn) -> None:
assert len(repos) == 1
repo = repos[0]

assert dir / "vcspull" == repo["dir"].parent
assert dir / "vcspull" / "libvcs" == repo["dir"]
assert path / "vcspull" == repo["path"].parent
assert path / "vcspull" / "libvcs" == repo["path"]


def test_relative_dir(load_yaml: LoadYAMLFn) -> None:
"""Test configuration files for vcspull support relative directories."""
dir, _, repos = load_yaml(
path, _, repos = load_yaml(
"""
./relativedir:
docutils: svn+http://svn.code.sf.net/p/docutils/code/trunk
"""
)

config_files = config.find_config_files(path=dir)
repos = config.load_configs(config_files, dir)
config_files = config.find_config_files(path=path)
repos = config.load_configs(config_files, path)

assert len(repos) == 1
repo = repos[0]

assert dir / "relativedir" == repo["dir"].parent
assert dir / "relativedir" / "docutils" == repo["dir"]
assert path / "relativedir" == repo["path"].parent
assert path / "relativedir" / "docutils" == repo["path"]
4 changes: 2 additions & 2 deletions tests/test_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ def test_expandenv_and_homevars() -> None:
config1_expanded = extract_repos(config1)
config2_expanded = extract_repos(config2)

paths = [r["dir"].parent for r in config1_expanded]
paths = [r["path"].parent for r in config1_expanded]
assert expand_dir(pathlib.Path("${HOME}/github_projects/")) in paths
assert expand_dir(pathlib.Path("~/study/")) in paths
assert expand_dir(pathlib.Path("~")) in paths

paths = [r["dir"].parent for r in config2_expanded]
paths = [r["path"].parent for r in config2_expanded]
assert expand_dir(pathlib.Path("${HOME}/github_projects/")) in paths
assert expand_dir(pathlib.Path("~/study/")) in paths

Expand Down
Loading