def test_update_submodule(workspace_path: Path, git_server: GitServer) -> None: top_url = git_server.add_repo("top") sub_url = git_server.add_repo("sub", add_to_manifest=False) git_server.add_submodule("top", url=sub_url, path=Path("sub")) tsrc.git.run(workspace_path, "clone", top_url, "--recurse-submodules") git_server.push_file("sub", "new.txt") git_server.update_submodule("top", "sub") top_path = workspace_path / "top" tsrc.git.run(top_path, "fetch") tsrc.git.run(top_path, "reset", "--hard", "origin/master") tsrc.git.run(top_path, "submodule", "update", "--init", "--recursive") new_sub = top_path / "sub" / "new.txt" assert new_sub.exists()
def test_update_submodules( tsrc_cli: CLI, git_server: GitServer, workspace_path: Path ) -> None: """ Scenario: * Create repo 'sub1' containing a 'sub2' submodule * Create a repo 'top' containing the 'sub1' submodule * Add 'top' to the manifest * Run `tsrc init` * Create commit in sub2 * Update sub2 submodule in sub1 * Update sub1 submodule in sub2 * Run `tsrc sync` * Check that everything was updated """ git_server.add_repo("top") sub1_url = git_server.add_repo("sub1", add_to_manifest=False) sub2_url = git_server.add_repo("sub2", add_to_manifest=False) git_server.add_submodule("sub1", url=sub2_url, path=Path("sub2")) git_server.add_submodule("top", url=sub1_url, path=Path("sub1")) tsrc_cli.run("init", git_server.manifest_url, "-r", "origin") git_server.push_file("sub2", "new.txt") git_server.update_submodule("sub1", "sub2") git_server.update_submodule("top", "sub1") tsrc_cli.run("sync") clone_path = workspace_path / "top" sub2_new_txt = clone_path / "sub1" / "sub2" / "new.txt" assert sub2_new_txt.exists(), "sub2 was not updated"