From 1b0aa19f20d102bf96ada7a1e77843eeef20985c Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 4 Apr 2024 12:57:31 +0200 Subject: git_repo: Add blob writer method Also extends the tests accordingly. --- src/buildtool/file_system/git_repo.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/buildtool/file_system/git_repo.hpp') diff --git a/src/buildtool/file_system/git_repo.hpp b/src/buildtool/file_system/git_repo.hpp index 885ddde1..60353a00 100644 --- a/src/buildtool/file_system/git_repo.hpp +++ b/src/buildtool/file_system/git_repo.hpp @@ -263,6 +263,15 @@ class GitRepo { anon_logger_ptr const& logger) noexcept -> std::pair>; + /// \brief Write given content as a blob into underlying object database. + /// Calling it from a fake repository allows thread-safe use. + /// \returns Git ID of the written blob, or nullopt on errors. + /// It guarantees the logger is called exactly once with fatal if failure. + /// Use with care, especially for large objects. + [[nodiscard]] auto WriteBlob(std::string const& content, + anon_logger_ptr const& logger) noexcept + -> std::optional; + /// \brief Get the object info related to a given path inside a Git tree. /// Unlike GetSubtreeFromTree, we here ignore errors and only return a value /// when all is successful. -- cgit v1.2.3