From 57edc4cbc764a9815f4990c54111e6ee9bcc8081 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 18 Feb 2025 09:50:34 +0100 Subject: {MR}GitApi: Drop inheritance --- src/buildtool/execution_api/git/git_api.hpp | 59 ++++------------------------- 1 file changed, 8 insertions(+), 51 deletions(-) (limited to 'src/buildtool/execution_api/git/git_api.hpp') diff --git a/src/buildtool/execution_api/git/git_api.hpp b/src/buildtool/execution_api/git/git_api.hpp index 3be2b8fd..22834007 100644 --- a/src/buildtool/execution_api/git/git_api.hpp +++ b/src/buildtool/execution_api/git/git_api.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -37,9 +36,7 @@ #include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/execution_api/common/artifact_blob.hpp" #include "src/buildtool/execution_api/common/common_api.hpp" -#include "src/buildtool/execution_api/common/execution_action.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" -#include "src/buildtool/execution_engine/dag/dag.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/file_system/git_tree.hpp" #include "src/buildtool/file_system/object_type.hpp" @@ -47,31 +44,15 @@ #include "src/buildtool/logging/logger.hpp" #include "src/utils/cpp/expected.hpp" -/// \brief API for local execution. -class GitApi final : public IExecutionApi { +class GitApi final { public: - GitApi() = delete; explicit GitApi(gsl::not_null const& repo_config) : repo_config_{repo_config} {} - [[nodiscard]] auto CreateAction( - ArtifactDigest const& /*root_digest*/, - std::vector const& /*command*/, - std::string const& /*cwd*/, - std::vector const& /*output_files*/, - std::vector const& /*output_dirs*/, - std::map const& /*env_vars*/, - std::map const& /*properties*/) const noexcept - -> IExecutionAction::Ptr final { - // Execution not supported from git cas - return nullptr; - } - // NOLINTNEXTLINE(google-default-arguments) [[nodiscard]] auto RetrieveToPaths( std::vector const& artifacts_info, - std::vector const& output_paths, - IExecutionApi const* /*alternative*/ = nullptr) const noexcept - -> bool override { + std::vector const& output_paths) const noexcept + -> bool { if (artifacts_info.size() != output_paths.size()) { Logger::Log(LogLevel::Error, "different number of digests and output paths."); @@ -118,13 +99,10 @@ class GitApi final : public IExecutionApi { return true; } - // NOLINTNEXTLINE(google-default-arguments) [[nodiscard]] auto RetrieveToFds( std::vector const& artifacts_info, std::vector const& fds, - bool raw_tree, - IExecutionApi const* /*alternative*/ = nullptr) const noexcept - -> bool override { + bool raw_tree) const noexcept -> bool { if (artifacts_info.size() != fds.size()) { Logger::Log(LogLevel::Error, "different number of digests and file descriptors."); @@ -190,12 +168,7 @@ class GitApi final : public IExecutionApi { [[nodiscard]] auto RetrieveToCas( std::vector const& artifacts_info, - IExecutionApi const& api) const noexcept -> bool override { - // Return immediately if target CAS is this CAS - if (this == &api) { - return true; - } - + IExecutionApi const& api) const noexcept -> bool { // Determine missing artifacts in other CAS. auto missing_artifacts_info = GetMissingArtifactsInfo( @@ -303,35 +276,19 @@ class GitApi final : public IExecutionApi { [[nodiscard]] auto RetrieveToMemory( Artifact::ObjectInfo const& artifact_info) const noexcept - -> std::optional override { + -> std::optional { return repo_config_->ReadBlobFromGitCAS(artifact_info.digest.hash()); } - /// NOLINTNEXTLINE(google-default-arguments) - [[nodiscard]] auto Upload(std::unordered_set&& /*blobs*/, - bool /*skip_find_missing*/ = false) const noexcept - -> bool override { - // Upload to git cas not supported - return false; - } - - [[nodiscard]] auto UploadTree( - std::vector const& - /*artifacts*/) const noexcept - -> std::optional override { - // Upload to git cas not supported - return std::nullopt; - } - [[nodiscard]] auto IsAvailable(ArtifactDigest const& digest) const noexcept - -> bool override { + -> bool { return repo_config_->ReadBlobFromGitCAS(digest.hash(), LogLevel::Trace) .has_value(); } [[nodiscard]] auto GetMissingDigests( std::unordered_set const& digests) const noexcept - -> std::unordered_set override { + -> std::unordered_set { std::unordered_set result; result.reserve(digests.size()); for (auto const& digest : digests) { -- cgit v1.2.3