From 24089af86a2f3a9d5e3e2405c0f076875bff406c Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Tue, 18 Jul 2023 12:29:18 +0200 Subject: [PATCH] make file:// conditional on depth --- planemo/galaxy/config.py | 2 +- planemo/git.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/planemo/galaxy/config.py b/planemo/galaxy/config.py index 70e5b18d7..4ec468175 100644 --- a/planemo/galaxy/config.py +++ b/planemo/galaxy/config.py @@ -1244,7 +1244,7 @@ def _install_galaxy_via_download(ctx, galaxy_root, env, kwds): def _install_galaxy_via_git(ctx, galaxy_root, env, kwds): gx_repo = _ensure_galaxy_repository_available(ctx, kwds) branch = _galaxy_branch(kwds) - command = git.command_clone(ctx, f"file://{gx_repo}", galaxy_root, branch=branch, depth=1) + command = git.command_clone(ctx, gx_repo, galaxy_root, branch=branch, depth=1) exit_code = shell(command, env=env) if exit_code != 0: raise Exception("Failed to clone Galaxy via git") diff --git a/planemo/git.py b/planemo/git.py index 524f543d8..aee1d8952 100644 --- a/planemo/git.py +++ b/planemo/git.py @@ -2,6 +2,7 @@ import os import subprocess +import urllib.parse from typing import ( Dict, List, @@ -87,7 +88,12 @@ def checkout(ctx, remote_repo, local_path, branch=None, remote="origin", from_br def command_clone( - ctx: "PlanemoCliContext", src: str, dest: str, mirror: bool = False, branch: Optional[str] = None, depth: Optional[int] = None + ctx: "PlanemoCliContext", + src: str, + dest: str, + mirror: bool = False, + branch: Optional[str] = None, + depth: Optional[int] = None, ) -> List[str]: """Produce a command-line string to clone a repository. @@ -100,6 +106,8 @@ def command_clone( cmd.extend(["--branch", branch]) if depth is not None: cmd.extend(["--depth", str(depth)]) + if urllib.parse.urlparse(src).scheme == "": + src = f"file://{src}" cmd.extend([src, dest]) return cmd