Skip to content

Commit bf5985b

Browse files
committed
refactor!: {VCS}Repo -> {VCS}Project
1 parent 79c3184 commit bf5985b

File tree

17 files changed

+126
-118
lines changed

17 files changed

+126
-118
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ git.clone(url='https://github.com/vcs-python/libvcs.git')
4141

4242
## Projects
4343

44-
Create a [`GitRepo`](https://libvcs.git-pull.com/projects/git.html#libvcs.projects.git.GitRepo)
45-
object of the project to inspect / checkout / update:
44+
Create a
45+
[`GitProject`](https://libvcs.git-pull.com/projects/git.html#libvcs.projects.git.GitProject) object
46+
of the project to inspect / checkout / update:
4647

4748
```python
4849
import pathlib
49-
from libvcs.projects.git import GitRepo
50+
from libvcs.projects.git import GitProject
5051

51-
repo = GitRepo(
52+
repo = GitProject(
5253
url="https://github.com/vcs-python/libvcs",
5354
dir=pathlib.Path().cwd() / "my_repo",
5455
remotes={

docs/projects/base.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
Base objects / classes for projects.
44

5-
Adding your own VCS / Extending libvcs can be done through subclassing `BaseRepo`.
5+
Adding your own VCS / Extending libvcs can be done through subclassing `BaseProject`.
66

77
```{eval-rst}
88
.. autosummary::
99
:recursive:
1010
11-
libvcs.projects.base.BaseRepo
11+
libvcs.projects.base.BaseProject
1212
```
1313

1414
```{eval-rst}

docs/projects/git.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Compare to:
1212
:recursive:
1313
1414
libvcs.projects.git.GitRemote
15-
libvcs.projects.git.GitRepo
15+
libvcs.projects.git.GitProject
1616
```
1717

1818
```{eval-rst}

docs/projects/hg.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ For mercurial, aka `hg(1)`.
66
.. autosummary::
77
:recursive:
88
9-
libvcs.projects.hg.MercurialRepo
9+
libvcs.projects.hg.MercurialProject
1010
```
1111

1212
```{eval-rst}

docs/projects/svn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ For subversion, aka `svn(1)`
66
.. autosummary::
77
:recursive:
88
9-
libvcs.projects.svn.SubversionRepo
9+
libvcs.projects.svn.SubversionProject
1010
```
1111

1212
```{eval-rst}

libvcs/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import logging
33

44
from .cmd.core import CmdLoggingAdapter
5-
from .projects.base import BaseRepo
6-
from .projects.git import GitRepo
7-
from .projects.hg import MercurialRepo
8-
from .projects.svn import SubversionRepo
5+
from .projects.base import BaseProject
6+
from .projects.git import GitProject
7+
from .projects.hg import MercurialProject
8+
from .projects.svn import SubversionProject
99

1010
__all__ = [
11-
"GitRepo",
12-
"MercurialRepo",
13-
"SubversionRepo",
14-
"BaseRepo",
11+
"GitProject",
12+
"MercurialProject",
13+
"SubversionProject",
14+
"BaseProject",
1515
"CmdLoggingAdapter",
1616
]
1717

libvcs/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from faker import Faker
1212

1313
from libvcs.cmd.core import run, which
14-
from libvcs.projects.git import GitRemoteDict, GitRepo
14+
from libvcs.projects.git import GitProject, GitRemoteDict
1515

1616
skip_if_git_missing = pytest.mark.skipif(
1717
not which("git"), reason="git is not available"
@@ -299,7 +299,7 @@ def hg_remote_repo(remote_repos_path: pathlib.Path):
299299
@pytest.fixture
300300
def git_repo(projects_path: pathlib.Path, git_remote_repo: pathlib.Path):
301301
"""Pre-made git clone of remote repo checked out to user's projects dir."""
302-
git_repo = GitRepo(
302+
git_repo = GitProject(
303303
url=f"file://{git_remote_repo}",
304304
dir=str(projects_path / "git_repo"),
305305
remotes={

libvcs/projects/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class VCSLocation(NamedTuple):
1616

1717

1818
def convert_pip_url(pip_url: str) -> VCSLocation:
19-
"""Return repo URL and revision by parsing `libvcs.base.BaseRepo.url`."""
19+
"""Return repo URL and revision by parsing `libvcs.base.BaseProject.url`."""
2020
error_message = (
2121
"Sorry, '%s' is a malformed VCS url. "
2222
"The format is <vcs>+<protocol>://<url>, "
@@ -32,7 +32,7 @@ def convert_pip_url(pip_url: str) -> VCSLocation:
3232
return VCSLocation(url=url, rev=rev)
3333

3434

35-
class BaseRepo:
35+
class BaseProject:
3636
"""Base class for repositories."""
3737

3838
#: log command output to buffer
@@ -54,7 +54,7 @@ def __init__(self, url, dir: StrOrPath, progress_callback=None, *args, **kwargs)
5454
>>> def progress_cb(output, timestamp):
5555
... sys.stdout.write(output)
5656
... sys.stdout.flush()
57-
>>> class Repo(BaseRepo):
57+
>>> class Repo(BaseProject):
5858
... bin_name = 'git'
5959
... def obtain(self, *args, **kwargs):
6060
... self.ensure_dir()
@@ -129,12 +129,12 @@ def run(
129129
"""Return combined stderr/stdout from a command.
130130
131131
This method will also prefix the VCS command bin_name. By default runs
132-
using the cwd `libvcs.base.BaseRepo.dir` of the repo.
132+
using the cwd `libvcs.base.BaseProject.dir` of the repo.
133133
134134
Parameters
135135
----------
136136
cwd : str
137-
dir command is run from, defaults to `libvcs.base.BaseRepo.dir`.
137+
dir command is run from, defaults to `libvcs.base.BaseProject.dir`.
138138
139139
check_returncode : bool
140140
Indicate whether a :exc:`~exc.CommandError` should be raised if return code

libvcs/projects/constants.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from typing import Dict, Literal, Type, Union
22

3-
from libvcs import GitRepo, MercurialRepo, SubversionRepo
3+
from libvcs import GitProject, MercurialProject, SubversionProject
44

55
#: Default VCS systems by string (in :data:`DEFAULT_VCS_CLASS_MAP`)
66
DEFAULT_VCS_LITERAL = Literal["git", "hg", "svn"]
77
#: Union of VCS Classes
8-
DEFAULT_VCS_CLASS_UNION = Type[Union[GitRepo, MercurialRepo, SubversionRepo]]
9-
#: String -> Class Map. ``DEFAULT_VCS_CLASS_MAP['git']`` -> :class:`~libvcs.git.GitRepo`
8+
DEFAULT_VCS_CLASS_UNION = Type[Union[GitProject, MercurialProject, SubversionProject]]
9+
#: ``str`` -> ``class`` Map. ``DEFAULT_VCS_CLASS_MAP['git']`` ->
10+
#: :class:`~libvcs.projects.git.GitProject`
1011
DEFAULT_VCS_CLASS_MAP: Dict[DEFAULT_VCS_LITERAL, DEFAULT_VCS_CLASS_UNION] = {
11-
"git": GitRepo,
12-
"svn": SubversionRepo,
13-
"hg": MercurialRepo,
12+
"git": GitProject,
13+
"svn": SubversionProject,
14+
"hg": MercurialProject,
1415
}

libvcs/projects/git.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
55
From https://github.com/saltstack/salt (Apache License):
66
7-
- [`GitRepo.remote`](libvcs.git.GitRepo.remote) (renamed to ``remote``)
8-
- [`GitRepo.remote`](libvcs.git.GitRepo.remote_set) (renamed to ``set_remote``)
7+
- [`GitProject.remote`](libvcs.git.GitProject.remote) (renamed to ``remote``)
8+
- [`GitProject.remote`](libvcs.git.GitProject.remote_set) (renamed to ``set_remote``)
99
1010
From pip (MIT Licnese):
1111
12-
- [`GitRepo.remote`](libvcs.git.GitRepo.remote_set) (renamed to ``set_remote``)
13-
- [`GitRepo.convert_pip_url`](libvcs.git.GitRepo.convert_pip_url`) (``get_url_rev``)
14-
- [`GitRepo.get_revision`](libvcs.git.GitRepo.get_revision)
15-
- [`GitRepo.get_git_version`](libvcs.git.GitRepo.get_git_version)
12+
- [`GitProject.remote`](libvcs.git.GitProject.remote_set) (renamed to ``set_remote``)
13+
- [`GitProject.convert_pip_url`](libvcs.git.GitProject.convert_pip_url`) (``get_url_rev``)
14+
- [`GitProject.get_revision`](libvcs.git.GitProject.get_revision)
15+
- [`GitProject.get_git_version`](libvcs.git.GitProject.get_git_version)
1616
""" # NOQA: E501
1717
import logging
1818
import pathlib
@@ -22,7 +22,7 @@
2222

2323
from .. import exc
2424
from ..projects.base import (
25-
BaseRepo,
25+
BaseProject,
2626
VCSLocation,
2727
convert_pip_url as base_convert_pip_url,
2828
)
@@ -134,12 +134,12 @@ class GitRemoteDict(TypedDict):
134134
push_url: str
135135

136136

137-
GitRepoRemoteDict = Dict[str, GitRemote]
137+
GitProjectRemoteDict = Dict[str, GitRemote]
138138
GitFullRemoteDict = Dict[str, GitRemoteDict]
139139
GitRemotesArgs = Union[None, GitFullRemoteDict, Dict[str, str]]
140140

141141

142-
class GitRepo(BaseRepo):
142+
class GitProject(BaseProject):
143143
bin_name = "git"
144144
schemes = ("git", "git+http", "git+https", "git+ssh", "git+git", "git+file")
145145

@@ -162,11 +162,11 @@ def __init__(
162162
.. code-block:: python
163163
164164
import os
165-
from libvcs.git import GitRepo
165+
from libvcs.git import GitProject
166166
167167
checkout = pathlib.Path(__name__) + '/' + 'my_libvcs'
168168
169-
repo = GitRepo(
169+
repo = GitProject(
170170
url="https://github.com/vcs-python/libvcs",
171171
dir=checkout,
172172
remotes={
@@ -177,11 +177,11 @@ def __init__(
177177
.. code-block:: python
178178
179179
import os
180-
from libvcs.git import GitRepo
180+
from libvcs.git import GitProject
181181
182182
checkout = pathlib.Path(__name__) + '/' + 'my_libvcs'
183183
184-
repo = GitRepo(
184+
repo = GitProject(
185185
url="https://github.com/vcs-python/libvcs",
186186
dir=checkout,
187187
remotes={
@@ -197,10 +197,10 @@ def __init__(
197197
if "tls_verify" not in kwargs:
198198
self.tls_verify = False
199199

200-
self._remotes: GitRepoRemoteDict
200+
self._remotes: GitProjectRemoteDict
201201

202202
if remotes is None:
203-
self._remotes: GitRepoRemoteDict = {
203+
self._remotes: GitProjectRemoteDict = {
204204
"origin": GitRemote(name="origin", fetch_url=url, push_url=url)
205205
}
206206
elif isinstance(remotes, dict):
@@ -225,7 +225,7 @@ def __init__(
225225
fetch_url=url,
226226
push_url=url,
227227
)
228-
BaseRepo.__init__(self, url, dir, *args, **kwargs)
228+
BaseProject.__init__(self, url, dir, *args, **kwargs)
229229
self.url = self.chomp_protocol(
230230
(
231231
self._remotes.get("origin")
@@ -594,7 +594,7 @@ def status(self) -> dict:
594594
595595
Examples
596596
--------
597-
>>> git_repo = GitRepo(
597+
>>> git_repo = GitProject(
598598
... url=f'file://{create_git_remote_repo()}',
599599
... dir=tmp_path
600600
... )

0 commit comments

Comments
 (0)