git_repo
Utility functions for handling and fetching repo archives in git format.
Classes¶
Functions¶
get_cached_remote
¶
get_cached_remote(
git_uri: str,
cache_dir: Path,
checkout: Optional[str] = None,
) -> Repo
Return a cached remote repo.
This provides some error-checking for the cached repo, and will re-clone if the cached repo is in a detached head state.
Parameters:
git_uri
-
The remote git URI
TYPE:
str
cache_dir
-
The directory to cache the repo in
TYPE:
Path
checkout
-
The optional checkout ref to use
DEFAULT:
None
Returns:
-
Repo
-
The cached repo
get_repo_name
¶
get_repo_name(
repo_url: str, checkout: Optional[str] = None
) -> str
Construct the destination repo name from the repo URL and checkout.
template_repo_from_git
¶
template_repo_from_git(
git_uri: str,
locality: Locality,
cache_dir: Path,
checkout: Optional[str] = None,
) -> TemplateRepo
Return a template repo from a git URI.
- If the repo is remote, it will be cloned to the cache_dir and named after the repo and checkout value,
for example
mytemplate_main
. This allows for multiple versions of the same repo to be cached without a conflict. - If the repo is already cloned, it will not be cloned again.
- If the repo is local, it is not cloned but will check out
checkout
, and the local path is returned.