Skip to content

Commit

Permalink
util/git: Support Copier URI aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
doshitan committed Jan 30, 2025
1 parent d597da5 commit c63c42c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nava/platform/util/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from tempfile import TemporaryDirectory
from typing import Any, Self

# TODO: reimplment get_repo functionality here and also consider additionally
# supporting slightly clearer `github:` prefix
from copier.vcs import get_repo


class GitProject:
def __init__(self, dir: Path):
Expand Down Expand Up @@ -32,7 +36,7 @@ def clone_if_necessary(cls, repo_uri: str) -> Generator[Self, None, None]:
else:
with TemporaryDirectory() as dir:
dir_path = Path(dir)
clone_result = clone_to(repo_uri, dir_path)
clone_result = clone_to(get_repo(repo_uri), dir_path)
clone_result.check_returncode()

yield cls(dir_path)
Expand Down Expand Up @@ -166,7 +170,6 @@ def is_a_git_worktree(dir: Path) -> bool:
return result.stdout.strip() == "true"


# TODO: could use copier.vcs.clone?
def clone_to(url: str, dest: Path, ref: str | None = None) -> subprocess.CompletedProcess[str]:
clone_result = run_text(["git", "clone", "--filter=blob:none", url, dest])

Expand Down

0 comments on commit c63c42c

Please sign in to comment.