diff options
Diffstat (limited to 'src/buildtool/serve_api/serve_service/source_tree.hpp')
-rw-r--r-- | src/buildtool/serve_api/serve_service/source_tree.hpp | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/src/buildtool/serve_api/serve_service/source_tree.hpp b/src/buildtool/serve_api/serve_service/source_tree.hpp index a74de455..030d33ee 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.hpp +++ b/src/buildtool/serve_api/serve_service/source_tree.hpp @@ -17,6 +17,7 @@ #include <filesystem> #include <memory> +#include <mutex> #include <optional> #include <string> #include <vector> @@ -27,22 +28,38 @@ #include "src/buildtool/execution_api/common/create_execution_api.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/file_system/symlinks_map/pragma_special.hpp" +#include "src/buildtool/file_system/symlinks_map/resolve_symlinks_map.hpp" #include "src/buildtool/logging/logger.hpp" class SourceTreeService final : public justbuild::just_serve::SourceTree::Service { public: + using ServeCommitTreeResponse = + ::justbuild::just_serve::ServeCommitTreeResponse; + using ServeArchiveTreeResponse = + ::justbuild::just_serve::ServeArchiveTreeResponse; + // Retrieve the Git-subtree identifier from a given Git commit. // // There are no method-specific errors. auto ServeCommitTree( ::grpc::ServerContext* context, const ::justbuild::just_serve::ServeCommitTreeRequest* request, - ::justbuild::just_serve::ServeCommitTreeResponse* response) - -> ::grpc::Status override; + ServeCommitTreeResponse* response) -> ::grpc::Status override; + + // Retrieve the Git-subtree identifier for the tree obtained + // by unpacking an archive with a given blob identifier. + // + // There are no method-specific errors. + auto ServeArchiveTree( + ::grpc::ServerContext* context, + const ::justbuild::just_serve::ServeArchiveTreeRequest* request, + ServeArchiveTreeResponse* response) -> ::grpc::Status override; private: + mutable std::shared_mutex mutex_; std::shared_ptr<Logger> logger_{std::make_shared<Logger>("serve-service")}; // remote execution endpoint @@ -51,12 +68,48 @@ class SourceTreeService final // local api gsl::not_null<IExecutionApi::Ptr> const local_api_{ CreateExecutionApi(std::nullopt)}; + // symlinks resolver map + ResolveSymlinksMap resolve_symlinks_map_{CreateResolveSymlinksMap()}; [[nodiscard]] static auto GetSubtreeFromCommit( std::filesystem::path const& repo_path, std::string const& commit, std::string const& subdir, std::shared_ptr<Logger> const& logger) -> std::optional<std::string>; + + [[nodiscard]] static auto GetSubtreeFromTree( + std::filesystem::path const& repo_path, + std::string const& tree_id, + std::string const& subdir, + std::shared_ptr<Logger> const& logger) -> std::optional<std::string>; + + [[nodiscard]] static auto GetBlobFromRepo( + std::filesystem::path const& repo_path, + std::string const& blob_id, + std::shared_ptr<Logger> const& logger) -> std::optional<std::string>; + + [[nodiscard]] auto SyncArchive(std::string const& tree_id, + std::filesystem::path const& repo_path, + bool sync_tree, + ServeArchiveTreeResponse* response) + -> ::grpc::Status; + + [[nodiscard]] auto ResolveContentTree( + std::string const& tree_id, + std::filesystem::path const& repo_path, + std::optional<PragmaSpecial> const& resolve_special, + bool sync_tree, + ServeArchiveTreeResponse* response) -> ::grpc::Status; + + [[nodiscard]] auto ImportToGit( + std::filesystem::path const& unpack_path, + std::filesystem::path const& archive_tree_id_file, + std::string const& content, + std::string const& archive_type, + std::string const& subdir, + std::optional<PragmaSpecial> const& resolve_special, + bool sync_tree, + ServeArchiveTreeResponse* response) -> ::grpc::Status; }; #endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_SERVE_SERVICE_SOURCE_TREE_HPP |