From 541ba9586b8a3aabe90f2dd01d994428dfab4cb9 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 13 Nov 2023 12:17:53 +0100 Subject: "git tree" repositories: honor "inherit env" In the specification of the action generating a fixed git tree, also honor "inherit env", i.e., inherit the environment variables specified in this field from the environment just-mr is invoked in. As the expected output is fixed ahead of time anyway, this lack of isolation does not affect correctness. --- src/other_tools/repo_map/repos_to_setup_map.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/other_tools/repo_map') diff --git a/src/other_tools/repo_map/repos_to_setup_map.cpp b/src/other_tools/repo_map/repos_to_setup_map.cpp index a72903d1..a65a6c50 100644 --- a/src/other_tools/repo_map/repos_to_setup_map.cpp +++ b/src/other_tools/repo_map/repos_to_setup_map.cpp @@ -611,6 +611,24 @@ void GitTreeCheckout(ExpressionPtr const& repo_desc, } } } + std::vector inherit_env{}; + auto repo_desc_inherit_env = + repo_desc->Get("inherit env", Expression::none_t{}); + if (repo_desc_inherit_env.IsNotNull() and repo_desc_inherit_env->IsList()) { + for (auto const& envvar : repo_desc_inherit_env->List()) { + if (envvar->IsString()) { + inherit_env.emplace_back(envvar->String()); + } + else { + (*logger)( + fmt::format("GitTreeCheckout: Not a variable name in the " + "specification of \"inherit env\": {}", + envvar->ToString()), + /*fatal=*/true); + return; + } + } + } // check "special" pragma auto repo_desc_pragma = repo_desc->At("pragma"); auto pragma_special = repo_desc_pragma @@ -632,6 +650,7 @@ void GitTreeCheckout(ExpressionPtr const& repo_desc, TreeIdInfo tree_id_info = { .hash = repo_desc_hash->get()->String(), .env_vars = std::move(env), + .inherit_env = std::move(inherit_env), .command = std::move(cmd), .ignore_special = pragma_special_value == PragmaSpecial::Ignore, .absent = not fetch_absent and pragma_absent_value}; -- cgit v1.2.3