From cf04253130030bc28866d10aa1f8fe1353643d42 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 24 Nov 2023 11:31:42 +0100 Subject: Refactoring RepositoryConfig With the introduction of 'just serve', export targets can now be built also independently from one another based on their corresponding minimal repository configuration, as stored in the target cache key. In this context, this commit changes the RepositoryConfig usage from one global (static) instance to pointers passed as necessary throughout the code. --- src/buildtool/execution_api/local/local_api.hpp | 26 +++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/buildtool/execution_api/local/local_api.hpp') diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index c04e82f4..f919e9c9 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -24,6 +24,7 @@ #include "fmt/core.h" #include "gsl/gsl" +#include "src/buildtool/common/repository_config.hpp" #include "src/buildtool/compatibility/compatibility.hpp" #include "src/buildtool/compatibility/native_support.hpp" #include "src/buildtool/execution_api/bazel_msg/bazel_blob.hpp" @@ -38,6 +39,10 @@ /// \brief API for local execution. class LocalApi final : public IExecutionApi { public: + explicit LocalApi(std::optional> + repo_config = std::nullopt) + : repo_config_{std::move(repo_config)} {} + auto CreateAction( ArtifactDigest const& root_digest, std::vector const& command, @@ -74,12 +79,13 @@ class LocalApi final : public IExecutionApi { info.digest, output_paths[i]); if (not infos) { if (Compatibility::IsCompatible()) { - // infos not availablble, and in compatible mode cannot + // infos not available, and in compatible mode cannot // fall back to git return false; } - if (not GitApi().RetrieveToPaths({info}, - {output_paths[i]})) { + if (repo_config_ and + not GitApi(repo_config_.value()) + .RetrieveToPaths({info}, {output_paths[i]})) { return false; } } @@ -92,12 +98,13 @@ class LocalApi final : public IExecutionApi { info.digest, IsExecutableObject(info.type)); if (not blob_path) { if (Compatibility::IsCompatible()) { - // infos not availablble, and in compatible mode cannot + // infos not available, and in compatible mode cannot // fall back to git return false; } - if (not GitApi().RetrieveToPaths({info}, - {output_paths[i]})) { + if (repo_config_ and + not GitApi(repo_config_.value()) + .RetrieveToPaths({info}, {output_paths[i]})) { return false; } } @@ -140,11 +147,13 @@ class LocalApi final : public IExecutionApi { info.ToString(), fd); if (Compatibility::IsCompatible()) { - // infos not availablble, and in compatible mode cannot + // infos not available, and in compatible mode cannot // fall back to git return false; } - if (not GitApi().RetrieveToFds({info}, {fd}, raw_tree)) { + if (repo_config_ and + not GitApi(repo_config_.value()) + .RetrieveToFds({info}, {fd}, raw_tree)) { return false; } } @@ -413,6 +422,7 @@ class LocalApi final : public IExecutionApi { } private: + std::optional> repo_config_{}; gsl::not_null storage_ = &Storage::Instance(); }; -- cgit v1.2.3