From 3dc81b4b5a89f4e37af45ec9954723c79c3017cf Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 29 Jan 2024 16:27:40 +0100 Subject: serve source tree: Increase server-side granularity in response statuses For archives and Git repositories we should ensure that not finding the witnessing entity (archive content blob or Git commit, respectively) results in a distinct status in the response to a request that sets up roots on the serve endpoint. This will allow just-mr to better handle its interaction with the serve endpoint. --- src/buildtool/file_system/git_repo.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (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 05bcfaf3..09e65402 100644 --- a/src/buildtool/file_system/git_repo.hpp +++ b/src/buildtool/file_system/git_repo.hpp @@ -15,7 +15,13 @@ #ifndef INCLUDED_SRC_BUILDTOOL_FILE_SYSTEM_GIT_REPO_HPP #define INCLUDED_SRC_BUILDTOOL_FILE_SYSTEM_GIT_REPO_HPP +#include #include +#include +#include +#include +#include +#include #include "src/buildtool/common/bazel_types.hpp" #include "src/buildtool/file_system/git_cas.hpp" @@ -178,12 +184,15 @@ class GitRepo { /// \brief Get the tree id of a subtree given the root commit /// Calling it from a fake repository allows thread-safe use. - /// Returns the subtree hash, as a string, or nullopt if failure. + /// Returns an error + data union, where at index 0 is a flag stating the + /// nature of the error on failure (true is fatal, false is non-fatal, i.e., + /// commit not found), and at index 1 is the subtree hash on success. /// It guarantees the logger is called exactly once with fatal if failure. [[nodiscard]] auto GetSubtreeFromCommit( std::string const& commit, std::string const& subdir, - anon_logger_ptr const& logger) noexcept -> std::optional; + anon_logger_ptr const& logger) noexcept + -> std::variant; /// \brief Get the tree id of a subtree given the root tree hash /// Calling it from a fake repository allows thread-safe use. -- cgit v1.2.3