diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-11-13 12:17:53 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-11-13 15:40:15 +0100 |
commit | 541ba9586b8a3aabe90f2dd01d994428dfab4cb9 (patch) | |
tree | 2c6924809d8ee2606807ef20daeff235b9a7c0a3 /src/other_tools/repo_map | |
parent | 6d01670b08688a075e8a4f1b297573281c2c4607 (diff) | |
download | justbuild-541ba9586b8a3aabe90f2dd01d994428dfab4cb9.tar.gz |
"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.
Diffstat (limited to 'src/other_tools/repo_map')
-rw-r--r-- | src/other_tools/repo_map/repos_to_setup_map.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
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<std::string> 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}; |