def run(args: argparse.Namespace) -> None: workspace_path = args.workspace_path or Path.cwd() cfg_path = workspace_path / ".tsrc" / "config.yml" if cfg_path.exists(): raise tsrc.Error( f"Workspace already configured. `{cfg_path}` already exists") ui.info_1("Configuring workspace in", ui.bold, workspace_path) workspace_config = WorkspaceConfig( manifest_url=args.manifest_url, manifest_branch=args.manifest_branch, clone_all_repos=args.clone_all_repos, repo_groups=args.groups or [], shallow_clones=args.shallow_clones, singular_remote=args.singular_remote, ) workspace_config.save_to_file(cfg_path) workspace = Workspace(workspace_path) workspace.update_manifest() manifest = workspace.get_manifest() workspace.repos = repos_from_config(manifest, workspace_config) workspace.clone_missing() workspace.set_remotes() workspace.perform_filesystem_operations() ui.info_2("Workspace initialized") ui.info_2("Configuration written in", ui.bold, workspace.cfg_path)
def run(args: argparse.Namespace) -> None: manifest = tsrc.manifest.load(args.manifest_path) workspace = get_workspace(args) workspace.repos = repos_from_config(manifest, workspace.config) workspace.clone_missing() workspace.set_remotes() workspace.perform_filesystem_operations(manifest=manifest)
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 apply_manifest(workspace: tsrc.Workspace, manifest_path: Path, **kwargs: Any) -> None: """ apply a local manifest file """ ui.info_1("Applying manifest from", manifest_path) manifest = tsrc.manifest.load(manifest_path) workspace.repos = repos_from_config(manifest, workspace.config) workspace.clone_missing() workspace.set_remotes() workspace.perform_filesystem_operations()
def init( url: str, workspace_path: Optional[Path] = None, groups: Optional[List[str]] = None, branch: str = "master", clone_all_repos: bool = False, shallow: bool = False, singular_remote: Optional[str] = None, ) -> None: """ initialize a new workspace""" path_as_str = workspace_path or os.getcwd() workspace_path = Path(path_as_str) cfg_path = workspace_path / ".tsrc" / "config.yml" if cfg_path.exists(): raise tsrc.Error("Workspace already configured with file " + cfg_path) ui.info_1("Configuring workspace in", ui.bold, workspace_path) workspace_config = WorkspaceConfig( manifest_url=url, manifest_branch=branch, clone_all_repos=clone_all_repos, repo_groups=groups or [], shallow_clones=shallow, singular_remote=singular_remote, ) workspace_config.save_to_file(cfg_path) workspace = Workspace(workspace_path) workspace.update_manifest() manifest = workspace.get_manifest() workspace.repos = repos_from_config(manifest, workspace_config) workspace.clone_missing() workspace.set_remotes() workspace.perform_filesystem_operations() ui.info_2("Workspace initialized") ui.info_2("Configuration written in", ui.bold, workspace.cfg_path)