From 65944566d8d3ae81d3dc3acb8c82944f5698ca5d Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 15 Feb 2023 17:12:15 +0100 Subject: structure cleanup: move remote operations of GitRepo to other_tools... ...in order to not include unwanted dependencies in just proper. The new class extends the GitRepo class used for just's Git tree operations and gets used in all of just-mr's async maps. --- src/buildtool/file_system/git_cas.cpp | 38 ----------------------------------- 1 file changed, 38 deletions(-) (limited to 'src/buildtool/file_system/git_cas.cpp') diff --git a/src/buildtool/file_system/git_cas.cpp b/src/buildtool/file_system/git_cas.cpp index efb464ef..2a4a7142 100644 --- a/src/buildtool/file_system/git_cas.cpp +++ b/src/buildtool/file_system/git_cas.cpp @@ -30,44 +30,6 @@ extern "C" { namespace { -constexpr std::size_t kOIDRawSize{GIT_OID_RAWSZ}; -constexpr std::size_t kOIDHexSize{GIT_OID_HEXSZ}; - -[[nodiscard]] auto GitLastError() noexcept -> std::string { - git_error const* err{nullptr}; - if ((err = git_error_last()) != nullptr and err->message != nullptr) { - return fmt::format("error code {}: {}", err->klass, err->message); - } - return ""; -} - -[[nodiscard]] auto GitObjectID(std::string const& id, - bool is_hex_id = false) noexcept - -> std::optional { - if (id.size() < (is_hex_id ? kOIDHexSize : kOIDRawSize)) { - Logger::Log(LogLevel::Error, - "invalid git object id {}", - is_hex_id ? id : ToHexString(id)); - return std::nullopt; - } - git_oid oid{}; - if (is_hex_id and git_oid_fromstr(&oid, id.c_str()) == 0) { - return oid; - } - if (not is_hex_id and - git_oid_fromraw( - &oid, - reinterpret_cast(id.data()) // NOLINT - ) == 0) { - return oid; - } - Logger::Log(LogLevel::Error, - "parsing git object id {} failed with:\n{}", - is_hex_id ? id : ToHexString(id), - GitLastError()); - return std::nullopt; -} - [[nodiscard]] auto GitTypeToObjectType(git_object_t const& type) noexcept -> std::optional { switch (type) { -- cgit v1.2.3