pmb.helpers.git.get_path: new function (!1848)

Get the path to the repository, which is either the default one in the
work dir, or a user-specified one in args.
This commit is contained in:
Oliver Smith 2019-12-27 23:13:28 +01:00 committed by Alexey Min
parent bbe3f5a219
commit 107c9f8b06
No known key found for this signature in database
GPG key ID: EBF5ECFFFEE34DED
2 changed files with 61 additions and 2 deletions

View file

@ -25,8 +25,19 @@ import pmb.config
import pmb.helpers.run
def get_path(args, name_repo):
""" Get the path to the repository, which is either the default one in the
work dir, or a user-specified one in args.
:returns: full path to repository """
if name_repo == "pmaports":
return args.aports
return args.work + "/cache_git/" + name_repo
def clone(args, name_repo, shallow=True):
""" Clone a git repository to $WORK/cache_git/$name_repo.
""" Clone a git repository to $WORK/cache_git/$name_repo (or to the
overridden path set in args, as with pmbootstrap --aports).
:param name_repo: short alias used for the repository name, from
pmb.config.git_repos (e.g. "aports_upstream",
@ -38,7 +49,7 @@ def clone(args, name_repo, shallow=True):
raise ValueError("No git repository configured for " + name_repo)
# Skip if already checked out
path = args.work + "/cache_git/" + name_repo
path = get_path(args, name_repo)
if os.path.exists(path):
return