From bcd000bed5f98b906ea4761ebe7422bca477672b Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 3 Nov 2023 11:22:46 +0100 Subject: fs_utils: Only accept strings as 'checkouts' map values While we don't want to fail if the 'checkouts' map values are not strings, we shouldn't just accept non-string values either, instead we should warn the user and continue without them. --- src/buildtool/storage/fs_utils.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/buildtool/storage/fs_utils.cpp') diff --git a/src/buildtool/storage/fs_utils.cpp b/src/buildtool/storage/fs_utils.cpp index f2241fc9..f6055579 100644 --- a/src/buildtool/storage/fs_utils.cpp +++ b/src/buildtool/storage/fs_utils.cpp @@ -24,9 +24,16 @@ namespace StorageUtils { auto GetGitRoot(LocalPathsPtr const& just_mr_paths, std::string const& repo_url) noexcept -> std::filesystem::path { if (just_mr_paths->git_checkout_locations.contains(repo_url)) { - return std::filesystem::absolute(ToNormalPath(std::filesystem::path{ - just_mr_paths->git_checkout_locations[repo_url] - .get()})); + if (just_mr_paths->git_checkout_locations[repo_url].is_string()) { + return std::filesystem::absolute(ToNormalPath(std::filesystem::path{ + just_mr_paths->git_checkout_locations[repo_url] + .get()})); + } + Logger::Log( + LogLevel::Warning, + "Retrieving Git checkout location: key {} has non-string value {}", + nlohmann::json(repo_url).dump(), + just_mr_paths->git_checkout_locations[repo_url].dump()); } auto repo_url_as_path = std::filesystem::absolute( ToNormalPath(std::filesystem::path(repo_url))); -- cgit v1.2.3