Skip to content

Commit 3b3a5de

Browse files
committed
refactor!: More Repo -> Project name changes
1 parent 126c1a6 commit 3b3a5de

File tree

7 files changed

+50
-49
lines changed

7 files changed

+50
-49
lines changed

libvcs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Repo package for libvcs."""
1+
"""Project package for libvcs."""
22
import logging
33

44
from .cmd.core import CmdLoggingAdapter

libvcs/conftest.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,25 @@ def clean():
120120
return dir
121121

122122

123-
class CreateRepoCallbackProtocol(Protocol):
123+
class CreateProjectCallbackProtocol(Protocol):
124124
def __call__(self, remote_repo_path: pathlib.Path):
125125
...
126126

127127

128-
class CreateRepoCallbackFixtureProtocol(Protocol):
128+
class CreateProjectCallbackFixtureProtocol(Protocol):
129129
def __call__(
130130
self,
131131
remote_repos_path: Optional[pathlib.Path] = None,
132132
remote_repo_name: Optional[str] = None,
133-
remote_repo_post_init: Optional[CreateRepoCallbackProtocol] = None,
133+
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
134134
):
135135
...
136136

137137

138138
def _create_git_remote_repo(
139139
remote_repos_path: pathlib.Path,
140140
remote_repo_name: str,
141-
remote_repo_post_init: Optional[CreateRepoCallbackProtocol] = None,
141+
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
142142
) -> pathlib.Path:
143143
remote_repo_path = remote_repos_path / remote_repo_name
144144
run(["git", "init", remote_repo_name], cwd=remote_repos_path)
@@ -157,7 +157,7 @@ def create_git_remote_repo(remote_repos_path: pathlib.Path, faker: Faker):
157157
def fn(
158158
remote_repos_path: pathlib.Path = remote_repos_path,
159159
remote_repo_name: Optional[str] = None,
160-
remote_repo_post_init: Optional[CreateRepoCallbackProtocol] = None,
160+
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
161161
):
162162
return _create_git_remote_repo(
163163
remote_repos_path=remote_repos_path,
@@ -192,7 +192,7 @@ def git_remote_repo(remote_repos_path: pathlib.Path):
192192
def _create_svn_remote_repo(
193193
remote_repos_path: pathlib.Path,
194194
remote_repo_name: str,
195-
remote_repo_post_init: Optional[CreateRepoCallbackProtocol] = None,
195+
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
196196
) -> pathlib.Path:
197197
"""Create a test SVN repo to for checkout / commit purposes"""
198198

@@ -213,7 +213,7 @@ def create_svn_remote_repo(remote_repos_path: pathlib.Path, faker: Faker):
213213
def fn(
214214
remote_repos_path: pathlib.Path = remote_repos_path,
215215
remote_repo_name: Optional[str] = None,
216-
remote_repo_post_init: Optional[CreateRepoCallbackProtocol] = None,
216+
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
217217
):
218218
return _create_svn_remote_repo(
219219
remote_repos_path=remote_repos_path,
@@ -243,7 +243,7 @@ def svn_remote_repo(remote_repos_path: pathlib.Path) -> pathlib.Path:
243243
def _create_hg_remote_repo(
244244
remote_repos_path: pathlib.Path,
245245
remote_repo_name: str,
246-
remote_repo_post_init: Optional[CreateRepoCallbackProtocol] = None,
246+
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
247247
) -> pathlib.Path:
248248
"""Create a test hg repo to for checkout / commit purposes"""
249249
remote_repo_path = remote_repos_path / remote_repo_name
@@ -271,7 +271,7 @@ def create_hg_remote_repo(remote_repos_path: pathlib.Path, faker: Faker):
271271
def fn(
272272
remote_repos_path: pathlib.Path = remote_repos_path,
273273
remote_repo_name: Optional[str] = None,
274-
remote_repo_post_init: Optional[CreateRepoCallbackProtocol] = None,
274+
remote_repo_post_init: Optional[CreateProjectCallbackProtocol] = None,
275275
):
276276
return _create_hg_remote_repo(
277277
remote_repos_path=remote_repos_path,
@@ -321,9 +321,9 @@ def add_doctest_fixtures(
321321
tmp_path: pathlib.Path,
322322
home_default: pathlib.Path,
323323
gitconfig: pathlib.Path,
324-
create_git_remote_repo: CreateRepoCallbackFixtureProtocol,
325-
create_svn_remote_repo: CreateRepoCallbackFixtureProtocol,
326-
create_hg_remote_repo: CreateRepoCallbackFixtureProtocol,
324+
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
325+
create_svn_remote_repo: CreateProjectCallbackFixtureProtocol,
326+
create_hg_remote_repo: CreateProjectCallbackFixtureProtocol,
327327
git_repo: pathlib.Path,
328328
):
329329
doctest_namespace["tmp_path"] = tmp_path

libvcs/projects/base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Base class for Repository objects."""
1+
"""Base class for Projectsitory objects."""
22
import logging
33
import pathlib
44
from typing import NamedTuple
@@ -54,15 +54,15 @@ 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(BaseProject):
57+
>>> class Project(BaseProject):
5858
... bin_name = 'git'
5959
... def obtain(self, *args, **kwargs):
6060
... self.ensure_dir()
6161
... self.run(
6262
... ['clone', '--progress', self.url, self.dir],
6363
... log_in_real_time=True
6464
... )
65-
>>> r = Repo(
65+
>>> r = Project(
6666
... url=f'file://{create_git_remote_repo()}',
6767
... dir=str(tmp_path),
6868
... progress_callback=progress_cb
@@ -171,7 +171,8 @@ def ensure_dir(self, *args, **kwargs):
171171

172172
if not self.dir.exists():
173173
self.log.debug(
174-
"Repo directory for %s does not exist @ %s" % (self.repo_name, self.dir)
174+
"Project directory for %s does not exist @ %s"
175+
% (self.repo_name, self.dir)
175176
)
176177
mkdir_p(self.dir)
177178

tests/projects/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def progress_cb(output, timestamp):
5151
sys.stdout.write(output)
5252
sys.stdout.flush()
5353

54-
class Repo(BaseProject):
54+
class Project(BaseProject):
5555
bin_name = "git"
5656

5757
def obtain(self, *args, **kwargs):
5858
self.ensure_dir()
5959
self.run(["clone", "--progress", self.url, self.dir], log_in_real_time=True)
6060

61-
r = Repo(
61+
r = Project(
6262
url=f"file://{str(git_remote_repo)}",
6363
dir=str(tmp_path),
6464
progress_callback=progress_cb,

tests/projects/test_conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import pytest
44

55
from libvcs.cmd.core import which
6-
from libvcs.conftest import CreateRepoCallbackFixtureProtocol
6+
from libvcs.conftest import CreateProjectCallbackFixtureProtocol
77

88

99
@pytest.mark.skipif(not which("git"), reason="git is not available")
1010
def test_create_git_remote_repo(
11-
create_git_remote_repo: CreateRepoCallbackFixtureProtocol,
11+
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
1212
tmp_path: pathlib.Path,
1313
projects_path: pathlib.Path,
1414
):
@@ -20,7 +20,7 @@ def test_create_git_remote_repo(
2020

2121
@pytest.mark.skipif(not which("svn"), reason="svn is not available")
2222
def test_create_svn_remote_repo(
23-
create_svn_remote_repo: CreateRepoCallbackFixtureProtocol,
23+
create_svn_remote_repo: CreateProjectCallbackFixtureProtocol,
2424
tmp_path: pathlib.Path,
2525
projects_path: pathlib.Path,
2626
):

tests/projects/test_git.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from libvcs import exc
1313
from libvcs.cmd.core import run, which
14-
from libvcs.conftest import CreateRepoCallbackFixtureProtocol
14+
from libvcs.conftest import CreateProjectCallbackFixtureProtocol
1515
from libvcs.projects.git import (
1616
GitFullRemoteDict,
1717
GitProject,
@@ -25,9 +25,9 @@
2525
pytestmark = pytest.mark.skip(reason="git is not available")
2626

2727

28-
RepoTestFactory = Callable[..., GitProject]
29-
RepoTestFactoryLazyKwargs = Callable[..., dict]
30-
RepoTestFactoryRemotesLazyExpected = Callable[..., GitFullRemoteDict]
28+
ProjectTestFactory = Callable[..., GitProject]
29+
ProjectTestFactoryLazyKwargs = Callable[..., dict]
30+
ProjectTestFactoryRemotesLazyExpected = Callable[..., GitFullRemoteDict]
3131

3232

3333
@pytest.mark.parametrize(
@@ -52,8 +52,8 @@
5252
)
5353
def test_repo_git_obtain_initial_commit_repo(
5454
tmp_path: pathlib.Path,
55-
constructor: RepoTestFactory,
56-
lazy_constructor_options: RepoTestFactoryLazyKwargs,
55+
constructor: ProjectTestFactory,
56+
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
5757
):
5858
"""initial commit repos return 'initial'.
5959
@@ -94,8 +94,8 @@ def test_repo_git_obtain_initial_commit_repo(
9494
def test_repo_git_obtain_full(
9595
tmp_path: pathlib.Path,
9696
git_remote_repo,
97-
constructor: RepoTestFactory,
98-
lazy_constructor_options: RepoTestFactoryLazyKwargs,
97+
constructor: ProjectTestFactory,
98+
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
9999
):
100100
git_repo: GitProject = constructor(**lazy_constructor_options(**locals()))
101101
git_repo.obtain()
@@ -130,8 +130,8 @@ def test_repo_update_handle_cases(
130130
tmp_path: pathlib.Path,
131131
git_remote_repo: pathlib.Path,
132132
mocker: MockerFixture,
133-
constructor: RepoTestFactory,
134-
lazy_constructor_options: RepoTestFactoryLazyKwargs,
133+
constructor: ProjectTestFactory,
134+
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
135135
):
136136
git_repo: GitProject = constructor(**lazy_constructor_options(**locals()))
137137
git_repo.obtain() # clone initial repo
@@ -174,8 +174,8 @@ def test_progress_callback(
174174
tmp_path: pathlib.Path,
175175
git_remote_repo: pathlib.Path,
176176
mocker: MockerFixture,
177-
constructor: RepoTestFactory,
178-
lazy_constructor_options: RepoTestFactoryLazyKwargs,
177+
constructor: ProjectTestFactory,
178+
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
179179
):
180180
def progress_callback_spy(output, timestamp):
181181
assert isinstance(output, str)
@@ -297,9 +297,9 @@ def progress_callback_spy(output, timestamp):
297297
def test_remotes(
298298
projects_path: pathlib.Path,
299299
git_remote_repo: pathlib.Path,
300-
constructor: RepoTestFactory,
301-
lazy_constructor_options: RepoTestFactoryLazyKwargs,
302-
lazy_remote_expected: RepoTestFactoryRemotesLazyExpected,
300+
constructor: ProjectTestFactory,
301+
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
302+
lazy_remote_expected: ProjectTestFactoryRemotesLazyExpected,
303303
):
304304
repo_name = "myrepo"
305305
remote_name = "myremote"
@@ -409,11 +409,11 @@ def test_remotes(
409409
def test_remotes_update_repo(
410410
projects_path: pathlib.Path,
411411
git_remote_repo: pathlib.Path,
412-
constructor: RepoTestFactory,
413-
lazy_constructor_options: RepoTestFactoryLazyKwargs,
414-
lazy_remote_dict: RepoTestFactoryRemotesLazyExpected,
415-
lazy_remote_expected: RepoTestFactoryRemotesLazyExpected,
416-
create_git_remote_repo: CreateRepoCallbackFixtureProtocol,
412+
constructor: ProjectTestFactory,
413+
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
414+
lazy_remote_dict: ProjectTestFactoryRemotesLazyExpected,
415+
lazy_remote_expected: ProjectTestFactoryRemotesLazyExpected,
416+
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
417417
):
418418
repo_name = "myrepo"
419419
remote_name = "myremote"
@@ -479,8 +479,8 @@ def test_git_get_url_and_rev_from_pip_url():
479479
def test_remotes_preserves_git_ssh(
480480
projects_path: pathlib.Path,
481481
git_remote_repo: pathlib.Path,
482-
constructor: RepoTestFactory,
483-
lazy_constructor_options: RepoTestFactoryLazyKwargs,
482+
constructor: ProjectTestFactory,
483+
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
484484
):
485485
# Regression test for #14
486486
repo_name = "myexamplegit"
@@ -520,8 +520,8 @@ def test_remotes_preserves_git_ssh(
520520
)
521521
def test_private_ssh_format(
522522
tmpdir: pathlib.Path,
523-
constructor: RepoTestFactory,
524-
lazy_constructor_options: RepoTestFactoryLazyKwargs,
523+
constructor: ProjectTestFactory,
524+
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
525525
):
526526
pip_url_kwargs = {
527527
"pip_url": "git+ssh://github.com:/tmp/omg/private_ssh_repo",
@@ -729,7 +729,7 @@ def test_extract_status_c(fixture: str, expected_result: dict):
729729

730730

731731
def test_repo_git_remote_checkout(
732-
create_git_remote_repo: CreateRepoCallbackFixtureProtocol,
732+
create_git_remote_repo: CreateProjectCallbackFixtureProtocol,
733733
tmp_path: pathlib.Path,
734734
projects_path: pathlib.Path,
735735
):

tests/projects/test_svn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
from libvcs.cmd.core import which
8-
from libvcs.conftest import CreateRepoCallbackFixtureProtocol
8+
from libvcs.conftest import CreateProjectCallbackFixtureProtocol
99
from libvcs.projects.svn import SubversionProject
1010
from libvcs.shortcuts import create_repo_from_pip_url
1111

@@ -33,7 +33,7 @@ def test_repo_svn(tmp_path: pathlib.Path, svn_remote_repo):
3333

3434

3535
def test_repo_svn_remote_checkout(
36-
create_svn_remote_repo: CreateRepoCallbackFixtureProtocol,
36+
create_svn_remote_repo: CreateProjectCallbackFixtureProtocol,
3737
tmp_path: pathlib.Path,
3838
projects_path: pathlib.Path,
3939
):

0 commit comments

Comments
 (0)