hookup branch

This commit is contained in:
svlandeg 2020-09-10 12:00:34 +02:00
parent 97d99f7efa
commit a36766d153
2 changed files with 5 additions and 3 deletions

View File

@ -337,7 +337,8 @@ def git_sparse_checkout(repo: str, subpath: str, dest: Path, *, branch: str = "m
missings = " ".join([x[1:] for x in ret.stdout.split() if x.startswith("?")])
if not missings:
err = f"Could not find any relevant files for '{subpath}'. " \
f"Did you specify a correct and complete path within repo '{repo}'?"
f"Did you specify a correct and complete path within repo '{repo}' " \
f"and branch {branch}?"
msg.fail(err, exits=1)
cmd = f"git -C {tmp_dir} fetch-pack {git_repo} {missings}"
_attempt_run_command(cmd)

View File

@ -28,7 +28,7 @@ def project_clone_cli(
"""
if dest is None:
dest = Path.cwd() / name
project_clone(name, dest, repo=repo)
project_clone(name, dest, repo=repo, branch=branch)
def project_clone(
@ -43,13 +43,14 @@ def project_clone(
name (str): Name of subdirectory to clone.
dest (Path): Destination path of cloned project.
repo (str): URL of Git repo containing project templates.
branch (str): The branch to clone from
"""
dest = ensure_path(dest)
check_clone(name, dest, repo)
project_dir = dest.resolve()
repo_name = re.sub(r"(http(s?)):\/\/github.com/", "", repo)
try:
git_sparse_checkout(repo, name, dest)
git_sparse_checkout(repo, name, dest, branch=branch)
except subprocess.CalledProcessError:
err = f"Could not clone '{name}' from repo '{repo_name}'"
msg.fail(err, exits=1)