summaryrefslogtreecommitdiff
path: root/src/other_tools/ops_maps/git_update_map.hpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-02-20 12:00:57 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-02-20 17:18:10 +0100
commita7cc305a3a6e2886a4f7ec7b8fd9943ff45f286d (patch)
tree544d491293fae297478f959ad84be731f469b02d /src/other_tools/ops_maps/git_update_map.hpp
parentca54778751856d77f7da2dba051c473a488f7d1e (diff)
downloadjustbuild-a7cc305a3a6e2886a4f7ec7b8fd9943ff45f286d.tar.gz
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.
Diffstat (limited to 'src/other_tools/ops_maps/git_update_map.hpp')
-rw-r--r--src/other_tools/ops_maps/git_update_map.hpp25
1 files changed, 17 insertions, 8 deletions
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<std::string, std::string>;
+struct RepoDescriptionForUpdating {
+ std::string repo{};
+ std::string branch{};
+ std::vector<std::string> 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<StringPair, std::string>;
+using GitUpdateMap = AsyncMapConsumer<RepoDescriptionForUpdating, std::string>;
namespace std {
template <>
-struct hash<StringPair> {
- [[nodiscard]] auto operator()(StringPair const& ct) const noexcept
- -> std::size_t {
+struct hash<RepoDescriptionForUpdating> {
+ [[nodiscard]] auto operator()(
+ RepoDescriptionForUpdating const& ct) const noexcept -> std::size_t {
size_t seed{};
- hash_combine<std::string>(&seed, ct.first);
- hash_combine<std::string>(&seed, ct.second);
+ hash_combine<std::string>(&seed, ct.repo);
+ hash_combine<std::string>(&seed, ct.branch);
return seed;
}
};
@@ -46,4 +55,4 @@ struct hash<StringPair> {
std::vector<std::string> 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