From d276dc6d6269dbeeccf779648eff10ce7797e7a1 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 24 Jan 2024 14:28:47 +0100 Subject: serve source tree: Distdir tree should end up in Git cache The purpose of the requests for the tree of an archive, commit, or distdir also includes making those trees available for future builds on the serve endpoint, which currently means being in a known Git repository. This commit ensures the distdir tree reqeust also includes the import of the resulting tree from CAS into the Git cache (if the tree is not already in a Git repsoitory). --- src/buildtool/serve_api/serve_service/source_tree.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/buildtool/serve_api/serve_service/source_tree.hpp') diff --git a/src/buildtool/serve_api/serve_service/source_tree.hpp b/src/buildtool/serve_api/serve_service/source_tree.hpp index 763762f6..8dd4021e 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.hpp +++ b/src/buildtool/serve_api/serve_service/source_tree.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "gsl/gsl" @@ -135,7 +136,15 @@ class SourceTreeService final bool sync_tree, ServeArchiveTreeResponse* response) -> ::grpc::Status; - [[nodiscard]] auto ImportToGit( + /// \brief Common import-to-git utility, used by both archives and distdirs. + /// \returns An error + data union, where at index 0 is the error message on + /// failure and at index 1 is the root tree id of the committed directory on + /// success. + [[nodiscard]] auto CommonImportToGit(std::filesystem::path const& root_path, + std::string const& commit_message) + -> std::variant; + + [[nodiscard]] auto ArchiveImportToGit( std::filesystem::path const& unpack_path, std::filesystem::path const& archive_tree_id_file, std::string const& content, @@ -149,6 +158,13 @@ class SourceTreeService final std::string const& tree_id, std::filesystem::path const& repo_path, std::shared_ptr const& logger) -> bool; + + [[nodiscard]] auto DistdirImportToGit( + std::string const& tree_id, + std::string const& content_id, + std::unordered_map const& content_list, + bool sync_tree, + ServeDistdirTreeResponse* response) -> ::grpc::Status; }; #endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_SERVE_SERVICE_SOURCE_TREE_HPP -- cgit v1.2.3