def assert_invalid_schema(tmp_path: Path, contents: str) -> Error: manifest_path = tmp_path / "manifest.yml" manifest_path.write_text(textwrap.dedent(contents)) try: load_manifest(manifest_path) except InvalidConfig as error: return error pytest.fail("Did not raise InvalidConfig")
def test_no_url_and_no_remote(tmp_path: Path) -> None: contents = """ repos: - dest: foo remotes: [] """ manifest_path = tmp_path / "manifest.yml" manifest_path.write_text(contents) with pytest.raises(InvalidConfig): load_manifest(manifest_path)
def test_multiple_manifest_branches( workspace_path: Path, git_server: GitServer ) -> None: git_server.add_repo("foo") git_server.manifest.change_branch("devel") git_server.add_repo("bar") run_git(workspace_path, "clone", git_server.manifest_url) manifest_yml = workspace_path / "manifest/manifest.yml" manifest = load_manifest(manifest_yml) assert len(manifest.get_repos()) == 1 run_git(workspace_path / "manifest", "reset", "--hard", "origin/devel") manifest = load_manifest(manifest_yml) assert len(manifest.get_repos()) == 2
def get_repos( self, groups: Optional[List[str]] = None, all_: bool = False ) -> List[str]: manifest_path = self.tmp_path / "manifest.yml" manifest_path.write_text(self.contents) manifest = load_manifest(manifest_path) return [repo.dest for repo in manifest.get_repos(groups=groups, all_=all_)]
def run(args: argparse.Namespace) -> None: manifest = load_manifest(args.manifest_path) num_jobs = get_num_jobs(args) workspace = get_workspace(args) workspace.repos = repos_from_config(manifest, workspace.config) workspace.clone_missing(num_jobs=num_jobs) workspace.set_remotes(num_jobs=num_jobs) workspace.perform_filesystem_operations(manifest=manifest)
def assert_valid_schema(tmp_path: Path, contents: str) -> Manifest: manifest_path = tmp_path / "manifest.yml" manifest_path.write_text(textwrap.dedent(contents)) res = load_manifest(manifest_path) return res
def main(args): # if manifest argument starts with http, fetch file to local .manifest.yml # otherwise, read in file at path. if args.manifest.startswith('http'): resp = requests.get(args.manifest) with open('.manifest.yml','w') as f: f.write(resp.text) manifest_file = '.manifest.yml' else: manifest_file = args.manifest manifest_path = Path(manifest_file) manifest = load_manifest(manifest_path) # create group_list dict containing a list of repos in each group group_list = {} for group in manifest.group_list.groups: repo_list = [] for repo in manifest.get_repos(groups = [group]): repo_list.append( {'dest': repo.dest, 'url': repo.remotes[0].url, 'branch': repo.branch, }) group_list[group] = repo_list # create site_config to hold structure for each line/site site_config={} with open('master_configuration_set') as csvfile: reader = csv.DictReader(decomment(csvfile), delimiter = ' ', skipinitialspace=True) for row in reader: # create key of the site, with dict values of row site_config[row['site']] = dict(row) # allow overriding of group with custom yaml, with filename # specified in scm_branch column if row['scm_group'] == 'custom': scm_conf = get_custom_yaml(row['scm_branch']) else: # get scm_conf from tsrc group, update the branch with the one # specified in the row scm_conf = group_list[row['scm_group']] for repo in scm_conf: repo['branch'] = row['scm_branch'] # we use deepcopy to avoid a reference to scm_conf that would get # overwritten on the next loop site_config[row['site']]['scm_conf'] = deepcopy(scm_conf) output = ruamel.yaml.dump({'site_config': site_config}, default_flow_style=False) if args.outfile: with open(args.outfile, 'w') as f: f.write(output) else: print(output)
def get_manifest(self) -> Manifest: return load_manifest(self.clone_path / "manifest.yml")
def read_remote_manifest(workspace_path: Path, git_server: GitServer) -> Manifest: run_git(workspace_path, "clone", git_server.manifest_url) manifest_yml = workspace_path / "manifest/manifest.yml" manifest = load_manifest(manifest_yml) return manifest