def test_git_manifest_sync_branch(self): # Two branches in the manifest repo: # - master: 3 projects: naoqi, libnaoqi and doc # - release-1.12: 2 projects: naoqi and doc, but doc stays with the # 'master' branch manifest_url = create_git_repo(self.tmp, "manifest.git", with_release_branch=True) create_git_repo(self.tmp, "naoqi", with_release_branch=True) create_git_repo(self.tmp, "libnaoqi") create_git_repo(self.tmp, "doc") xml = """ <manifest> <remote name="origin" fetch="{tmp}/srv" /> <project name="naoqi.git" path="naoqi" /> <project name="libnaoqi.git" path="lib/libnaoqi" /> <project name="doc" path="doc" /> </manifest> """ xml = xml.format(tmp=self.tmp) push_file(self.tmp, "manifest.git", "default.xml", xml) xml = """ <manifest> <remote name="origin" fetch="{tmp}/srv" revision="release-1.12" /> <project name="naoqi.git" path="naoqi" /> <project name="doc" path="doc" revision="master" /> </manifest> """ xml = xml.format(tmp=self.tmp) push_file(self.tmp, "manifest.git", "default.xml", xml, branch="release-1.12") master_root = os.path.join(self.tmp, "work", "master") release_root = os.path.join(self.tmp, "work", "release-1.12") qisys.sh.mkdir(master_root, recursive=True) qisys.sh.mkdir(release_root, recursive=True) master_wt = qisys.worktree.create(master_root) release_wt = qisys.worktree.create(release_root) master_manifest = qisrc.sync.fetch_load_manifest(master_wt, manifest_url, branch="master") release_manifest = qisrc.sync.fetch_load_manifest(release_wt, manifest_url, branch="release-1.12") qisrc.sync.init_worktree(master_wt, master_manifest) qisrc.sync.init_worktree(release_wt, release_manifest) release_srcs = [p.src for p in release_wt.projects] self.assertEqual(release_srcs, ["doc", "manifest/default", "naoqi"]) naoqi_release = release_wt.get_project("naoqi") readme = read_readme(naoqi_release.path) self.assertEqual(readme, "naoqi on release-1.12\n") self.assertEqual(naoqi_release.remote, "origin") self.assertEqual(naoqi_release.branch, "release-1.12") master_srcs = [p.src for p in master_wt.projects] self.assertEqual(master_srcs, ["doc", "lib/libnaoqi", "manifest/default", "naoqi"]) naoqi_master = master_wt.get_project("naoqi") readme = read_readme(naoqi_master.path) self.assertEqual(readme, "naoqi\n") self.assertEqual(naoqi_master.remote, "origin") self.assertEqual(naoqi_master.branch, "master")
def test_manifest_wrong_revision(self): manifest_url = create_git_repo(self.tmp, "manifest", with_release_branch=True) xml = """ <manifest> <remote fetch="git@foo" name="origin" revision="release-1.12" /> </manifest> """ push_file(self.tmp, "manifest", "default.xml", xml, branch="release-1.12") worktree = qisys.worktree.create(self.tmp) qisrc.sync.clone_project(worktree, manifest_url) fetched_manifest = qisrc.sync.fetch_load_manifest(worktree, manifest_url, branch="release-1.12") qisrc.sync.init_worktree(worktree, fetched_manifest) worktree.set_manifest_project("manifest/default") manifest_projects = worktree.get_manifest_projects() self.assertEqual(len(manifest_projects), 1) manifest_path = manifest_projects[0].path readme = read_readme(manifest_path) self.assertEqual(readme, "manifest on release-1.12\n")