summaryrefslogtreecommitdiff
path: root/src/buildtool/serve_api/serve_service/source_tree.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-01-24 14:28:47 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-01-26 14:51:43 +0100
commitd276dc6d6269dbeeccf779648eff10ce7797e7a1 (patch)
tree925c80186f61a2b9510deb50182333d8275a8001 /src/buildtool/serve_api/serve_service/source_tree.hpp
parent0d3860c4bbfe81c7003f0ea1f1a01fc3a866daed (diff)
downloadjustbuild-d276dc6d6269dbeeccf779648eff10ce7797e7a1.tar.gz
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).
Diffstat (limited to 'src/buildtool/serve_api/serve_service/source_tree.hpp')
-rw-r--r--src/buildtool/serve_api/serve_service/source_tree.hpp18
1 files changed, 17 insertions, 1 deletions
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 <mutex>
#include <optional>
#include <string>
+#include <variant>
#include <vector>
#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<std::string, std::string>;
+
+ [[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<Logger> const& logger) -> bool;
+
+ [[nodiscard]] auto DistdirImportToGit(
+ std::string const& tree_id,
+ std::string const& content_id,
+ std::unordered_map<std::string, std::string> const& content_list,
+ bool sync_tree,
+ ServeDistdirTreeResponse* response) -> ::grpc::Status;
};
#endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_SERVE_SERVICE_SOURCE_TREE_HPP