Skip to content

Commit b309633

Browse files
committed
refactor! create_repo -> create_project
1 parent ae2fe46 commit b309633

File tree

6 files changed

+31
-29
lines changed

6 files changed

+31
-29
lines changed

libvcs/shortcuts.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
from libvcs.exc import InvalidPipURL, InvalidVCS
66

77

8-
def create_repo(
8+
def create_project(
99
url, vcs, progress_callback=None, *args, **kwargs
1010
) -> Union[GitProject, MercurialProject, SubversionProject]:
1111
r"""Return an object representation of a VCS repository.
1212
1313
Examples
1414
--------
15-
>>> from libvcs.shortcuts import create_repo
16-
>>> r = create_repo(
15+
>>> from libvcs.shortcuts import create_project
16+
>>> r = create_project(
1717
... url=f'file://{create_git_remote_repo()}',
1818
... vcs='git',
1919
... dir=tmp_path
@@ -36,16 +36,16 @@ def create_repo(
3636
raise InvalidVCS("VCS %s is not a valid VCS" % vcs)
3737

3838

39-
def create_repo_from_pip_url(
39+
def create_project_from_pip_url(
4040
pip_url, **kwargs
4141
) -> Union[GitProject, MercurialProject, SubversionProject]:
4242
r"""Return an object representation of a VCS repository via pip-style url.
4343
4444
Examples
4545
--------
4646
47-
>>> from libvcs.shortcuts import create_repo_from_pip_url
48-
>>> r = create_repo_from_pip_url(
47+
>>> from libvcs.shortcuts import create_project_from_pip_url
48+
>>> r = create_project_from_pip_url(
4949
... pip_url=f'git+{create_git_remote_repo()}',
5050
... dir=tmp_path
5151
... )

tests/projects/test_base.py

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

77
from libvcs.projects.base import BaseProject, convert_pip_url
8-
from libvcs.shortcuts import create_repo
8+
from libvcs.shortcuts import create_project
99

1010

1111
def test_repr():
12-
repo = create_repo(url="file://path/to/myrepo", dir="/hello/", vcs="git")
12+
repo = create_project(url="file://path/to/myrepo", dir="/hello/", vcs="git")
1313

1414
str_repo = str(repo)
1515
assert "GitProject" in str_repo

tests/projects/test_git.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
convert_pip_url as git_convert_pip_url,
2020
extract_status,
2121
)
22-
from libvcs.shortcuts import create_repo_from_pip_url
22+
from libvcs.shortcuts import create_project_from_pip_url
2323

2424
if not which("git"):
2525
pytestmark = pytest.mark.skip(reason="git is not available")
@@ -42,7 +42,7 @@
4242
},
4343
],
4444
[
45-
create_repo_from_pip_url,
45+
create_project_from_pip_url,
4646
lambda bare_dir, tmp_path, **kwargs: {
4747
"pip_url": f"git+file://{bare_dir}",
4848
"dir": tmp_path / "obtaining a bare repo",
@@ -83,7 +83,7 @@ def test_repo_git_obtain_initial_commit_repo(
8383
},
8484
],
8585
[
86-
create_repo_from_pip_url,
86+
create_project_from_pip_url,
8787
lambda git_remote_repo, tmp_path, **kwargs: {
8888
"pip_url": f"git+file://{git_remote_repo}",
8989
"dir": tmp_path / "myrepo",
@@ -118,7 +118,7 @@ def test_repo_git_obtain_full(
118118
},
119119
],
120120
[
121-
create_repo_from_pip_url,
121+
create_project_from_pip_url,
122122
lambda git_remote_repo, tmp_path, **kwargs: {
123123
"pip_url": f"git+file://{git_remote_repo}",
124124
"dir": tmp_path / "myrepo",
@@ -161,7 +161,7 @@ def test_repo_update_handle_cases(
161161
},
162162
],
163163
[
164-
create_repo_from_pip_url,
164+
create_project_from_pip_url,
165165
lambda git_remote_repo, tmp_path, progress_callback, **kwargs: {
166166
"pip_url": f"git+file://{git_remote_repo}",
167167
"dir": tmp_path / "myrepo",
@@ -285,7 +285,7 @@ def progress_callback_spy(output, timestamp):
285285
},
286286
],
287287
[
288-
create_repo_from_pip_url,
288+
create_project_from_pip_url,
289289
lambda git_remote_repo, projects_path, repo_name, **kwargs: {
290290
"pip_url": f"git+file://{git_remote_repo}",
291291
"dir": projects_path / repo_name,
@@ -468,7 +468,7 @@ def test_git_get_url_and_rev_from_pip_url():
468468
},
469469
],
470470
[
471-
create_repo_from_pip_url,
471+
create_project_from_pip_url,
472472
lambda git_remote_repo, dir, **kwargs: {
473473
"pip_url": f"git+file://{git_remote_repo}",
474474
"dir": dir,
@@ -510,7 +510,7 @@ def test_remotes_preserves_git_ssh(
510510
},
511511
],
512512
[
513-
create_repo_from_pip_url,
513+
create_project_from_pip_url,
514514
lambda bare_dir, tmp_path, **kwargs: {
515515
"pip_url": f"git+file://{bare_dir}",
516516
"dir": tmp_path / "obtaining a bare repo",
@@ -529,7 +529,7 @@ def test_private_ssh_format(
529529
}
530530

531531
with pytest.raises(exc.LibVCSException) as excinfo:
532-
create_repo_from_pip_url(**pip_url_kwargs)
532+
create_project_from_pip_url(**pip_url_kwargs)
533533
excinfo.match(r"is malformatted")
534534

535535

tests/projects/test_hg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55

66
from libvcs.cmd.core import run, which
7-
from libvcs.shortcuts import create_repo, create_repo_from_pip_url
7+
from libvcs.shortcuts import create_project, create_project_from_pip_url
88

99
if not which("hg"):
1010
pytestmark = pytest.mark.skip(reason="hg is not available")
@@ -13,7 +13,7 @@
1313
def test_repo_mercurial(tmp_path: pathlib.Path, projects_path, hg_remote_repo):
1414
repo_name = "my_mercurial_project"
1515

16-
mercurial_repo = create_repo_from_pip_url(
16+
mercurial_repo = create_project_from_pip_url(
1717
**{
1818
"pip_url": f"hg+file://{hg_remote_repo}",
1919
"dir": projects_path / repo_name,
@@ -45,7 +45,7 @@ def test_vulnerability_2022_03_12_command_injection(
4545
random_dir = tmp_path / "random"
4646
random_dir.mkdir()
4747
monkeypatch.chdir(str(random_dir))
48-
mercurial_repo = create_repo(
48+
mercurial_repo = create_project(
4949
url="--config=alias.clone=!touch ./HELLO", vcs="hg", dir="./"
5050
)
5151
with pytest.raises(Exception):

tests/projects/test_svn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from libvcs.cmd.core import which
88
from libvcs.conftest import CreateProjectCallbackFixtureProtocol
99
from libvcs.projects.svn import SubversionProject
10-
from libvcs.shortcuts import create_repo_from_pip_url
10+
from libvcs.shortcuts import create_project_from_pip_url
1111

1212
if not which("svn"):
1313
pytestmark = pytest.mark.skip(reason="svn is not available")
@@ -16,7 +16,7 @@
1616
def test_repo_svn(tmp_path: pathlib.Path, svn_remote_repo):
1717
repo_name = "my_svn_project"
1818

19-
svn_repo = create_repo_from_pip_url(
19+
svn_repo = create_project_from_pip_url(
2020
**{
2121
"pip_url": f"svn+file://{svn_remote_repo}",
2222
"dir": tmp_path / repo_name,

tests/test_shortcuts.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from libvcs import GitProject, MercurialProject, SubversionProject
66
from libvcs.exc import InvalidPipURL, InvalidVCS
7-
from libvcs.shortcuts import create_repo, create_repo_from_pip_url
7+
from libvcs.shortcuts import create_project, create_project_from_pip_url
88

99

1010
@pytest.mark.parametrize(
@@ -28,17 +28,17 @@
2828
),
2929
],
3030
)
31-
def test_create_repo_from_pip_url(
31+
def test_create_project_from_pip_url(
3232
tmp_path: pathlib.Path, repo_dict, repo_class, raises_exception
3333
):
3434
# add parent_dir via fixture
3535
repo_dict["dir"] = tmp_path / "repo_name"
3636

3737
if raises_exception:
3838
with pytest.raises(raises_exception):
39-
create_repo_from_pip_url(**repo_dict)
39+
create_project_from_pip_url(**repo_dict)
4040
else:
41-
repo = create_repo_from_pip_url(**repo_dict)
41+
repo = create_project_from_pip_url(**repo_dict)
4242
assert isinstance(repo, repo_class)
4343

4444

@@ -67,13 +67,15 @@ def test_create_repo_from_pip_url(
6767
),
6868
],
6969
)
70-
def test_create_repo(tmp_path: pathlib.Path, repo_dict, repo_class, raises_exception):
70+
def test_create_project(
71+
tmp_path: pathlib.Path, repo_dict, repo_class, raises_exception
72+
):
7173
# add parent_dir via fixture
7274
repo_dict["dir"] = tmp_path / "repo_name"
7375

7476
if raises_exception:
7577
with pytest.raises(raises_exception):
76-
create_repo(**repo_dict)
78+
create_project(**repo_dict)
7779
else:
78-
repo = create_repo(**repo_dict)
80+
repo = create_project(**repo_dict)
7981
assert isinstance(repo, repo_class)

0 commit comments

Comments
 (0)