From cbdba7e8e100fe1a2f1554da811c08bf1dac50d0 Mon Sep 17 00:00:00 2001 From: Johann Neuhauser Date: Fri, 29 Jul 2022 07:46:18 +0200 Subject: [PATCH] config: Fix repo-relative include file handling if no config file is given If we do not specify a configuration file for the "kas build" command, the repository anchor is set to the current working directory, which breaks the resolution of repo-relative include file paths in the IncludeHandler class if repo root != current working directory. Sets the repository anchor to the root path of the repository with fallback to KAS_WORK_DIR if we use .config.yaml from KAS_WORK_DIR. Signed-off-by: Johann Neuhauser Signed-off-by: Jan Kiszka --- kas/config.py | 2 +- kas/libkas.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/kas/config.py b/kas/config.py index b0a20ab..236d106 100644 --- a/kas/config.py +++ b/kas/config.py @@ -57,7 +57,7 @@ class Config: 'must be outside of versioning control') else: self.filenames = [os.path.join(ctx.kas_work_dir, CONFIG_YAML_FILE)] - self.top_repo_path = os.getcwd() + self.top_repo_path = Repo.get_root_path(ctx.kas_work_dir) self.handler = IncludeHandler(self.filenames, self.top_repo_path) self.repo_dict = self._get_repo_dict() diff --git a/kas/libkas.py b/kas/libkas.py index 33cbf18..4801d32 100644 --- a/kas/libkas.py +++ b/kas/libkas.py @@ -378,9 +378,8 @@ def ssh_no_host_key_check(): def setup_parser_common_args(parser): parser.add_argument('config', - help='Config file, using .config.yaml if none is ' - 'specified and using the current directory as ' - 'repository anchor', + help='Config file, using .config.yaml in KAS_WORK_DIR ' + 'if none is specified', nargs='?') parser.add_argument('--skip', help='Skip build steps',