From 34983c13ee6a7d58f8141a75e054373f9cca44ab Mon Sep 17 00:00:00 2001 From: Peter Hoyes Date: Fri, 8 Jul 2022 16:45:09 +0200 Subject: [PATCH] libcmds: Only checkout "missing" repositories in SetupReposStep There is a subtle bug in SetupReposStep that occurs when: * One or more repositories are reported as "missing" in InitSetupRepos. * SetupReposStep checks out the missing repositories. * SetupReposStep updates the repo_dict with all repositories in the configuration, some of which may only be partially defined and/or not checked out. * SetupReposStep passes this new, incorrect list of checked out repositories to the include handler in the next pass. * The include handler attempts to include a file from a partially defined repository, likely resulting in a "File not found" error because it is assumed to be a local repository. To fix this, keep track of the repositories that have been checked out by only adding repositories that have been reported as "missing" to ctx.config.repo_dict Now that ctx.config.repo_dict only contains checked out repositories, it is necessary to check missing repo names against the config dict instead. Signed-off-by: Peter Hoyes Signed-off-by: Jan Kiszka --- kas/libcmds.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kas/libcmds.py b/kas/libcmds.py index 0e2132f..d1641e5 100644 --- a/kas/libcmds.py +++ b/kas/libcmds.py @@ -370,21 +370,20 @@ class SetupReposStep(Command): logging.debug('Missing repos for complete config:\n%s', pprint.pformat(ctx.missing_repo_names)) - ctx.config.repo_dict = ctx.config._get_repo_dict() - ctx.missing_repos = [] for repo_name in ctx.missing_repo_names: - if repo_name not in ctx.config.repo_dict: + if repo_name not in ctx.config.get_repos_config(): logging.error('Include references unknown repo: %s', repo_name) sys.exit(1) - ctx.missing_repos.append(ctx.config.repo_dict[repo_name]) + ctx.missing_repos.append(ctx.config.get_repo(repo_name)) repos_fetch(ctx.missing_repos) for repo in ctx.missing_repos: repo.checkout() - ctx.config.repo_dict = ctx.config._get_repo_dict() + ctx.config.repo_dict.update( + {repo.name: repo for repo in ctx.missing_repos}) repo_paths = {r: ctx.config.repo_dict[r].path for r in ctx.config.repo_dict}