Skip to content

Commit f62c524

Browse files
authored
tests(remotes): git URL schemes in remotes (#419)
Fixes #425. Brings us closer to solving #49
2 parents deb5fdb + 8812897 commit f62c524

File tree

4 files changed

+57
-11
lines changed

4 files changed

+57
-11
lines changed

CHANGES

+10-4
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,23 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force
2121

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

24+
### Breaking changes
25+
26+
- Python 3.7 Dropped (#421)
27+
- libvcs: Bumped from 0.22.2 -> 0.24.0 (#419)
28+
29+
### Bug fixes
30+
31+
- Git Remote URLs: Fix bug that would cause git remotes with `@` to be chopped off after the
32+
protocol (#419, fixes #425)
33+
2434
### Development
2535

2636
- Refactor of two testsuites to used `NamedTuple` parametrization (#423):
2737

2838
- test_config_variations
2939
- test_updating_remote
3040

31-
### Breaking changes
32-
33-
- Python 3.7 Dropped (#421)
34-
3541
## vcspull v1.22.0 (2023-09-02)
3642

3743
_Maintenance only, no bug fixes, or new features_

poetry.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ vcspull = 'vcspull:cli.cli'
6060

6161
[tool.poetry.dependencies]
6262
python = "^3.9"
63-
libvcs = "~0.22.1"
63+
libvcs = "~0.24.0"
6464
colorama = ">=0.3.9"
6565
PyYAML = "^6.0"
6666

tests/test_sync.py

+42-2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,28 @@ class ConfigVariationTest(t.NamedTuple):
9797
""",
9898
remote_list=["secondremote"],
9999
),
100+
ConfigVariationTest(
101+
test_id="expanded_repo_style_with_unprefixed_remote",
102+
config_tpl="""
103+
{tmp_path}/study/myrepo:
104+
{CLONE_NAME}:
105+
repo: git+file://{dir}
106+
remotes:
107+
git_scheme_repo: [email protected]:tmux-python/tmuxp.git
108+
""",
109+
remote_list=["git_scheme_repo"],
110+
),
111+
ConfigVariationTest(
112+
test_id="expanded_repo_style_with_unprefixed_remote_2",
113+
config_tpl="""
114+
{tmp_path}/study/myrepo:
115+
{CLONE_NAME}:
116+
repo: git+file://{dir}
117+
remotes:
118+
git_scheme_repo: [email protected]:tony/vcspull.git
119+
""",
120+
remote_list=["git_scheme_repo"],
121+
),
100122
]
101123

102124

@@ -131,7 +153,6 @@ def test_config_variations(
131153
assert len(repos) == 1
132154

133155
for repo_dict in repos:
134-
repo_url = repo_dict["url"].replace("git+", "")
135156
repo: GitSync = update_repo(repo_dict)
136157
remotes = repo.remotes() or {}
137158
remote_names = set(remotes.keys())
@@ -142,7 +163,26 @@ def test_config_variations(
142163
for remote_name in remotes:
143164
current_remote = repo.remote(remote_name)
144165
assert current_remote is not None
145-
assert current_remote.fetch_url == repo_url
166+
assert repo_dict is not None
167+
assert isinstance(remote_name, str)
168+
if (
169+
"remotes" in repo_dict
170+
and isinstance(repo_dict["remotes"], dict)
171+
and remote_name in repo_dict["remotes"]
172+
):
173+
if repo_dict["remotes"][remote_name].fetch_url.startswith(
174+
"git+file://"
175+
):
176+
assert current_remote.fetch_url == repo_dict["remotes"][
177+
remote_name
178+
].fetch_url.replace(
179+
"git+", ""
180+
), "Final git remote should chop git+ prefix"
181+
else:
182+
assert (
183+
current_remote.fetch_url
184+
== repo_dict["remotes"][remote_name].fetch_url
185+
)
146186

147187

148188
class UpdatingRemoteFixture(t.NamedTuple):

0 commit comments

Comments
 (0)