diff options
Diffstat (limited to 'src/other_tools/ops_maps')
-rw-r--r-- | src/other_tools/ops_maps/TARGETS | 2 | ||||
-rw-r--r-- | src/other_tools/ops_maps/git_tree_fetch_map.cpp | 8 | ||||
-rw-r--r-- | src/other_tools/ops_maps/git_tree_fetch_map.hpp | 2 | ||||
-rw-r--r-- | src/other_tools/ops_maps/git_update_map.cpp | 87 | ||||
-rw-r--r-- | src/other_tools/ops_maps/git_update_map.hpp | 2 |
5 files changed, 57 insertions, 44 deletions
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS index 202f029b..587b8903 100644 --- a/src/other_tools/ops_maps/TARGETS +++ b/src/other_tools/ops_maps/TARGETS @@ -45,6 +45,7 @@ , ["src/buildtool/file_system", "git_cas"] , ["src/buildtool/multithreading", "async_map_consumer"] , ["src/buildtool/storage", "config"] + , ["src/other_tools/just_mr", "mirrors"] , ["src/other_tools/just_mr/progress_reporting", "progress"] , ["src/other_tools/just_mr/progress_reporting", "statistics"] , ["src/utils/cpp", "hash_combine"] @@ -127,6 +128,7 @@ , ["src/buildtool/multithreading", "async_map_consumer"] , ["src/buildtool/serve_api/remote", "serve_api"] , ["src/buildtool/storage", "config"] + , ["src/other_tools/just_mr", "mirrors"] , ["src/other_tools/just_mr/progress_reporting", "progress"] , ["src/other_tools/ops_maps", "critical_git_op_map"] , ["src/other_tools/ops_maps", "import_to_git_map"] diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp index d4e7c0f6..d5de57d9 100644 --- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp +++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp @@ -292,6 +292,7 @@ auto CreateGitTreeFetchMap( gsl::not_null<ImportToGitMap*> const& import_to_git_map, std::string const& git_bin, std::vector<std::string> const& launcher, + MirrorsPtr const& mirrors, ServeApi const* serve, gsl::not_null<StorageConfig const*> const& native_storage_config, StorageConfig const* compat_storage_config, @@ -304,6 +305,7 @@ auto CreateGitTreeFetchMap( import_to_git_map, git_bin, launcher, + mirrors, serve, native_storage_config, compat_storage_config, @@ -334,6 +336,7 @@ auto CreateGitTreeFetchMap( import_to_git_map, git_bin, launcher, + mirrors, serve, native_storage_config, compat_storage_config, @@ -524,8 +527,10 @@ auto CreateGitTreeFetchMap( std::copy(key.command.begin(), key.command.end(), std::back_inserter(cmdline)); + auto inherit_env = + MirrorsUtils::GetInheritEnv(mirrors, key.inherit_env); std::map<std::string, std::string> env{key.env_vars}; - for (auto const& k : key.inherit_env) { + for (auto const& k : inherit_env) { const char* v = std::getenv(k.c_str()); if (v != nullptr) { env[k] = std::string(v); @@ -571,6 +576,7 @@ auto CreateGitTreeFetchMap( key, git_bin, launcher, + mirrors, native_storage_config, compat_storage_config, local_api, diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.hpp b/src/other_tools/ops_maps/git_tree_fetch_map.hpp index 7f698247..1e3f5156 100644 --- a/src/other_tools/ops_maps/git_tree_fetch_map.hpp +++ b/src/other_tools/ops_maps/git_tree_fetch_map.hpp @@ -27,6 +27,7 @@ #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/serve_api/remote/serve_api.hpp" #include "src/buildtool/storage/config.hpp" +#include "src/other_tools/just_mr/mirrors.hpp" #include "src/other_tools/just_mr/progress_reporting/progress.hpp" #include "src/other_tools/ops_maps/critical_git_op_map.hpp" #include "src/other_tools/ops_maps/import_to_git_map.hpp" @@ -64,6 +65,7 @@ using GitTreeFetchMap = AsyncMapConsumer<GitTreeInfo, bool>; gsl::not_null<ImportToGitMap*> const& import_to_git_map, std::string const& git_bin, std::vector<std::string> const& launcher, + MirrorsPtr const& mirrors, ServeApi const* serve, gsl::not_null<StorageConfig const*> const& native_storage_config, StorageConfig const* compat_storage_config, diff --git a/src/other_tools/ops_maps/git_update_map.cpp b/src/other_tools/ops_maps/git_update_map.cpp index ddbec3bc..f22629f2 100644 --- a/src/other_tools/ops_maps/git_update_map.cpp +++ b/src/other_tools/ops_maps/git_update_map.cpp @@ -25,53 +25,54 @@ auto CreateGitUpdateMap( GitCASPtr const& git_cas, std::string const& git_bin, std::vector<std::string> const& launcher, + MirrorsPtr const& mirrors, gsl::not_null<StorageConfig const*> const& storage_config, gsl::not_null<JustMRStatistics*> const& stats, gsl::not_null<JustMRProgress*> const& progress, std::size_t jobs) -> GitUpdateMap { - auto update_commits = [git_cas, - git_bin, - launcher, - storage_config, - stats, - progress](auto /* unused */, - auto setter, - auto logger, - auto /* unused */, - auto const& key) { - // perform git update commit - auto git_repo = GitRepoRemote::Open(git_cas); // wrap the tmp odb - if (not git_repo) { - (*logger)( - fmt::format("Failed to open tmp Git repository for remote {}", - key.repo), - /*fatal=*/true); - return; - } - // setup wrapped logger - auto wrapped_logger = std::make_shared<AsyncMapConsumerLogger>( - [logger](auto const& msg, bool fatal) { - (*logger)( - fmt::format("While updating commit from remote:\n{}", msg), - fatal); - }); - // update commit - auto id = fmt::format("{}:{}", key.repo, key.branch); - progress->TaskTracker().Start(id); - auto new_commit = git_repo->UpdateCommitViaTmpRepo(*storage_config, - key.repo, - key.branch, - key.inherit_env, - git_bin, - launcher, - wrapped_logger); - progress->TaskTracker().Stop(id); - if (not new_commit) { - return; - } - stats->IncrementExecutedCounter(); - (*setter)(new_commit->c_str()); - }; + auto update_commits = + [git_cas, git_bin, launcher, mirrors, storage_config, stats, progress]( + auto /* unused */, + auto setter, + auto logger, + auto /* unused */, + auto const& key) { + // perform git update commit + auto git_repo = GitRepoRemote::Open(git_cas); // wrap the tmp odb + if (not git_repo) { + (*logger)(fmt::format( + "Failed to open tmp Git repository for remote {}", + key.repo), + /*fatal=*/true); + return; + } + // setup wrapped logger + auto wrapped_logger = std::make_shared<AsyncMapConsumerLogger>( + [logger](auto const& msg, bool fatal) { + (*logger)( + fmt::format("While updating commit from remote:\n{}", + msg), + fatal); + }); + auto inherit_env = + MirrorsUtils::GetInheritEnv(mirrors, key.inherit_env); + // update commit + auto id = fmt::format("{}:{}", key.repo, key.branch); + progress->TaskTracker().Start(id); + auto new_commit = git_repo->UpdateCommitViaTmpRepo(*storage_config, + key.repo, + key.branch, + inherit_env, + git_bin, + launcher, + wrapped_logger); + progress->TaskTracker().Stop(id); + if (not new_commit) { + return; + } + stats->IncrementExecutedCounter(); + (*setter)(new_commit->c_str()); + }; return AsyncMapConsumer<RepoDescriptionForUpdating, std::string>( update_commits, jobs); } diff --git a/src/other_tools/ops_maps/git_update_map.hpp b/src/other_tools/ops_maps/git_update_map.hpp index 1bf9256c..39ab61c8 100644 --- a/src/other_tools/ops_maps/git_update_map.hpp +++ b/src/other_tools/ops_maps/git_update_map.hpp @@ -24,6 +24,7 @@ #include "src/buildtool/file_system/git_cas.hpp" #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/storage/config.hpp" +#include "src/other_tools/just_mr/mirrors.hpp" #include "src/other_tools/just_mr/progress_reporting/progress.hpp" #include "src/other_tools/just_mr/progress_reporting/statistics.hpp" #include "src/utils/cpp/hash_combine.hpp" @@ -59,6 +60,7 @@ struct hash<RepoDescriptionForUpdating> { GitCASPtr const& git_cas, std::string const& git_bin, std::vector<std::string> const& launcher, + MirrorsPtr const& mirrors, gsl::not_null<StorageConfig const*> const& storage_config, // native storage config gsl::not_null<JustMRStatistics*> const& stats, |