From a7cc305a3a6e2886a4f7ec7b8fd9943ff45f286d Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 20 Feb 2024 12:00:57 +0100 Subject: git repo fetch: support "inherit env" When fetching git repositories, just-mr routinely shells out to git. In this case, allow the user to specify via "inherit env", which environment variables from the host environment should be made available in this action. Typical variables to inherit are ones providing credentials, like SSH_AUTH_SOCK. As the repository description specifies the commit that will be taken, and hence the resulting tree, correctness is not affected by the environement leaking in here. --- src/other_tools/ops_maps/git_update_map.hpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/other_tools/ops_maps/git_update_map.hpp') diff --git a/src/other_tools/ops_maps/git_update_map.hpp b/src/other_tools/ops_maps/git_update_map.hpp index 1978069a..e1aac2e3 100644 --- a/src/other_tools/ops_maps/git_update_map.hpp +++ b/src/other_tools/ops_maps/git_update_map.hpp @@ -23,19 +23,28 @@ #include "src/other_tools/git_operations/git_repo_remote.hpp" #include "src/utils/cpp/hash_combine.hpp" -using StringPair = std::pair; +struct RepoDescriptionForUpdating { + std::string repo{}; + std::string branch{}; + std::vector inherit_env{}; /*non-key!*/ + + [[nodiscard]] auto operator==(const RepoDescriptionForUpdating& other) const + -> bool { + return repo == other.repo and branch == other.branch; + } +}; /// \brief Maps a pair of repository url and branch to an updated commit hash. -using GitUpdateMap = AsyncMapConsumer; +using GitUpdateMap = AsyncMapConsumer; namespace std { template <> -struct hash { - [[nodiscard]] auto operator()(StringPair const& ct) const noexcept - -> std::size_t { +struct hash { + [[nodiscard]] auto operator()( + RepoDescriptionForUpdating const& ct) const noexcept -> std::size_t { size_t seed{}; - hash_combine(&seed, ct.first); - hash_combine(&seed, ct.second); + hash_combine(&seed, ct.repo); + hash_combine(&seed, ct.branch); return seed; } }; @@ -46,4 +55,4 @@ struct hash { std::vector const& launcher, std::size_t jobs) -> GitUpdateMap; -#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_GIT_UPDATE_MAP_HPP \ No newline at end of file +#endif // INCLUDED_SRC_OTHER_TOOLS_OPS_MAPS_GIT_UPDATE_MAP_HPP -- cgit v1.2.3