Skip to content

Commit 1ee1e78

Browse files
committed
Add test case for cloning submodules with relative path
1 parent ec2e2c8 commit 1ee1e78

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/test_submodule.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,3 +1350,23 @@ def test_submodule_update_unsafe_options_allowed(self, rw_repo):
13501350
for unsafe_option in unsafe_options:
13511351
with self.assertRaises(GitCommandError):
13521352
submodule.update(clone_multi_options=[unsafe_option], allow_unsafe_options=True)
1353+
1354+
@with_rw_directory
1355+
@_patch_git_config("protocol.file.allow", "always")
1356+
def test_submodule_update_relative_url(self, rwdir):
1357+
parent_path = osp.join(rwdir, "parent")
1358+
parent_repo = git.Repo.init(parent_path)
1359+
submodule_path = osp.join(rwdir, "module")
1360+
submodule_repo = git.Repo.init(submodule_path)
1361+
submodule_repo.git.commit(m="initial commit", allow_empty=True)
1362+
1363+
parent_repo.git.submodule("add", "../module", "module")
1364+
parent_repo.index.commit("add submodule with relative URL")
1365+
1366+
cloned_path = osp.join(rwdir, "cloned_repo")
1367+
cloned_repo = git.Repo.clone_from(parent_path, cloned_path)
1368+
1369+
cloned_repo.submodule_update(init=True, recursive=True)
1370+
1371+
has_module = any(sm.name == "module" for sm in cloned_repo.submodules)
1372+
assert has_module, "Relative submodule was not updated properly"

0 commit comments

Comments
 (0)