def test_init_submodules(tmpdir): foo_url = create_git_repo_with_submodules(tmpdir.strpath) worktree = create_worktree(tmpdir) clone_project(worktree, foo_url) foo = worktree.get_project("foo") bar_readme = os.path.join(foo.path, "bar", "README") assert os.path.exists(bar_readme)
def test_submodules(self): manifest_url = create_git_repo(self.tmp, "manifest") create_git_repo_with_submodules(self.tmp) xml = """ <manifest> <remote name="origin" fetch="{tmp}/srv" /> <project name="foo.git" path="foo" /> <project name="bar.git" path="foo/bar"/> </manifest> """ xml = xml.format(tmp=self.tmp) push_file(self.tmp, "manifest", "default.xml", xml) work = os.path.join(self.tmp, "work") worktree = qisrc.worktree.create(work) manifest = qisrc.sync.fetch_manifest(worktree, manifest_url) qisrc.sync.init_worktree(worktree, manifest) self.assertEqual(len(worktree.git_projects), 3)
def test_erasing_submodules_with_manifest_should_raise(self): manifest_url = create_git_repo(self.tmp, "manifest") create_git_repo_with_submodules(self.tmp) xml = """ <manifest> <remote name="origin" fetch="{tmp}/srv" /> <project name="foo.git" path="foo" /> <project name="bar.git" path="foo/bar"/> </manifest> """ xml = xml.format(tmp=self.tmp) push_file(self.tmp, "manifest", "default.xml", xml) work = os.path.join(self.tmp, "work") worktree = qisys.worktree.create(work) manifest = qisrc.sync.fetch_load_manifest(worktree, manifest_url) # pylint: disable-msg=E1101 with pytest.raises(Exception) as e: qisrc.sync.init_worktree(worktree, manifest) assert "is already a submodule of" in str(e.value)