From 0892b37ad69cafcaff91f8fcb000e5f9166249c1 Mon Sep 17 00:00:00 2001 From: Silvano Cirujano Cuesta Date: Wed, 16 Dec 2020 17:55:43 +0100 Subject: [PATCH] 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 Signed-off-by: Jan Kiszka --- kas/repos.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/kas/repos.py b/kas/repos.py index 8b5e517..598315a 100644 --- a/kas/repos.py +++ b/kas/repos.py @@ -114,26 +114,21 @@ class Repo: path = repo_config.get('path', None) disable_operations = False - if url is None: - # No version control operation on repository - if path is None: + if path is None: + if url is None: path = Repo.get_root_path(repo_fallback_path) logging.info('Using %s as root for repository %s', path, 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) + path = os.path.join(get_context().kas_work_dir, name) + elif 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 url is None: + # No version control operation on repository url = path 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': return GitRepo(name, url, path, refspec, layers, patches,