diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-01-29 16:27:40 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-01-31 17:15:44 +0100 |
commit | 3dc81b4b5a89f4e37af45ec9954723c79c3017cf (patch) | |
tree | b3f18bca1a29e3ff88013f282e6fb0efdd09aea9 /src/buildtool/file_system/git_repo.hpp | |
parent | c1827db24dbc8f0d6eca47c92f34d85bf6b2b128 (diff) | |
download | justbuild-3dc81b4b5a89f4e37af45ec9954723c79c3017cf.tar.gz |
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.
Diffstat (limited to 'src/buildtool/file_system/git_repo.hpp')
-rw-r--r-- | src/buildtool/file_system/git_repo.hpp | 13 |
1 files changed, 11 insertions, 2 deletions
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 <filesystem> #include <functional> +#include <optional> +#include <string> +#include <unordered_map> +#include <variant> +#include <vector> #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<std::string>; + anon_logger_ptr const& logger) noexcept + -> std::variant<bool, std::string>; /// \brief Get the tree id of a subtree given the root tree hash /// Calling it from a fake repository allows thread-safe use. |