From 9da24d46c64eaf4c7db65c0f67324801fafbf30d Mon Sep 17 00:00:00 2001 From: "Wenhan Zhu (Cosmos)" Date: Wed, 6 Sep 2023 20:50:57 -0400 Subject: [PATCH] add test for submodule path not owned by submodule case --- test/test_submodule.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/test_submodule.py b/test/test_submodule.py index d906a5d5b..8c98a671e 100644 --- a/test/test_submodule.py +++ b/test/test_submodule.py @@ -906,6 +906,28 @@ def assert_exists(sm, value=True): assert osp.isdir(sm_module_path) == dry_run # end for each dry-run mode + @with_rw_directory + def test_ignore_non_submodule_file(self, rwdir): + parent = git.Repo.init(rwdir) + + smp = osp.join(rwdir, "module") + os.mkdir(smp) + + with open(osp.join(smp, "a"), "w", encoding="utf-8") as f: + f.write('test\n') + + with open(osp.join(rwdir, ".gitmodules"), "w", encoding="utf-8") as f: + f.write("[submodule \"a\"]\n") + f.write(" path = module\n") + f.write(" url = https://github.com/chaconinc/DbConnector\n") + + parent.git.add(Git.polish_url(osp.join(smp, "a"))) + parent.git.add(Git.polish_url(osp.join(rwdir, ".gitmodules"))) + + parent.git.commit(message='test') + + assert len(parent.submodules) == 0 + @with_rw_directory def test_remove_norefs(self, rwdir): parent = git.Repo.init(osp.join(rwdir, "parent"))