diff options
Diffstat (limited to 'src/other_tools')
-rw-r--r-- | src/other_tools/just_mr/setup_utils.cpp | 63 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup_utils.hpp | 2 |
2 files changed, 65 insertions, 0 deletions
diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp index 07498441..864aa684 100644 --- a/src/other_tools/just_mr/setup_utils.cpp +++ b/src/other_tools/just_mr/setup_utils.cpp @@ -80,6 +80,57 @@ void WarnUnknownKeys(std::string const& name, ExpressionPtr const& repo_def) { return std::nullopt; } +[[nodiscard]] auto IsAbsent(ExpressionPtr const& repo_def) -> bool { + if (repo_def.IsNotNull() and repo_def->IsMap()) { + if (auto repo = repo_def->Get("repository", Expression::none_t{}); + repo.IsNotNull() and repo->IsMap()) { + if (auto pragma = repo->Get("pragma", Expression::none_t{}); + pragma.IsNotNull() and pragma->IsMap()) { + auto absent = pragma->Get("absent", Expression::none_t{}); + return absent.IsNotNull() and absent->IsBool() and + absent->Bool(); + } + } + } + return false; +} + +[[nodiscard]] auto IsNotContentFixed(ExpressionPtr const& repo_def) -> bool { + if (not repo_def.IsNotNull() or not repo_def->IsMap()) { + return false; + } + if (auto repo = repo_def->Get("repository", Expression::none_t{}); + repo.IsNotNull() and repo->IsMap()) { + // Check if type == "file" + auto type = repo->Get("type", Expression::none_t{}); + if (not type.IsNotNull() or not type->IsString()) { + return false; + } + if (type->String() == "file") { + auto pragma = repo->Get("pragma", Expression::none_t{}); + if (not pragma.IsNotNull() or not pragma->IsMap()) { + return true; // not content-fixed if not to_git + } + // Check for explicit to_git == true + if (auto to_git = pragma->Get("to_git", Expression::none_t{}); + to_git.IsNotNull() and to_git->IsBool() and to_git->Bool()) { + return false; + } + // Check for implicit to_git == true + if (auto special = pragma->Get("special", Expression::none_t{}); + special.IsNotNull() and special->IsString()) { + auto const& special_str = special->String(); + if (special_str == "resolve-partially" or + special_str == "resolve-completely") { + return false; + } + } + return true; // not content-fixed if not to_git + } + } + return false; +} + } // namespace namespace JustMR::Utils { @@ -92,6 +143,8 @@ void ReachableRepositories( std::unordered_set<std::string> include_repos_set; std::unordered_set<std::string> setup_repos_set; + bool absent_main = IsAbsent(repos->Get(main, Expression::none_t{})); + // traverse all bindings of main repository for (std::queue<std::string> to_process({main}); not to_process.empty(); to_process.pop()) { @@ -108,6 +161,16 @@ void ReachableRepositories( } WarnUnknownKeys(repo_name, repos_repo_name); + // Warn if main repo is marked absent and current repo (including main) + // is not content-fixed + if (absent_main and IsNotContentFixed(repos_repo_name)) { + Logger::Log(LogLevel::Warning, + "Found non-content-fixed repository {} as dependency " + "of absent main repository {}", + nlohmann::json(repo_name).dump(), + nlohmann::json(main).dump()); + } + // If the current repo is a computed one, process its target repo if (auto precomputed = GetTargetRepoIfPrecomputed(repos, repo_name)) { to_process.push(*std::move(precomputed)); diff --git a/src/other_tools/just_mr/setup_utils.hpp b/src/other_tools/just_mr/setup_utils.hpp index 6b0d8731..7dc482e6 100644 --- a/src/other_tools/just_mr/setup_utils.hpp +++ b/src/other_tools/just_mr/setup_utils.hpp @@ -63,6 +63,8 @@ struct SetupRepos { namespace Utils { /// \brief Get the repo dependency closure for a given main repository. +/// If main repository is absent, emits a warning for any reachable +/// non-content-fixed repository found. /// \param repos ExpressionPtr of Map type. void ReachableRepositories( ExpressionPtr const& repos, |