repos: refactor repo path calculation

Refactored repo path calculation eliminates duplicated code and aligns
the matching logic (with respect to url and path) with the
documentation.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Silvano Cirujano Cuesta 2020-12-16 17:55:43 +01:00 committed by Jan Kiszka
parent 1f1a21992d
commit 0892b37ad6

View File

@ -114,26 +114,21 @@ class Repo:
path = repo_config.get('path', None) path = repo_config.get('path', None)
disable_operations = False disable_operations = False
if url is None: if path is None:
# No version control operation on repository if url is None:
if path is None:
path = Repo.get_root_path(repo_fallback_path) path = Repo.get_root_path(repo_fallback_path)
logging.info('Using %s as root for repository %s', path, logging.info('Using %s as root for repository %s', path,
name) name)
else: else:
if not os.path.isabs(path): path = os.path.join(get_context().kas_work_dir, name)
# Relative pathes are assumed to start from work_dir elif not os.path.isabs(path):
path = os.path.join(get_context().kas_work_dir, path) # Relative pathes are assumed to start from work_dir
path = os.path.join(get_context().kas_work_dir, path)
if url is None:
# No version control operation on repository
url = path url = path
disable_operations = True disable_operations = True
else:
if path is None:
path = os.path.join(get_context().kas_work_dir, name)
else:
if not os.path.isabs(path):
# Relative pathes are assumed to start from work_dir
path = os.path.join(get_context().kas_work_dir, path)
if typ == 'git': if typ == 'git':
return GitRepo(name, url, path, refspec, layers, patches, return GitRepo(name, url, path, refspec, layers, patches,