From ddf48a60029bed958fb2cf0238dbb0bca0b770fb Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 11 Sep 2024 10:21:13 +0200 Subject: Add to ProtocolTraits static functions that provide protocol-specific behaviour --- src/buildtool/common/protocol_traits.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/buildtool/common/protocol_traits.hpp') diff --git a/src/buildtool/common/protocol_traits.hpp b/src/buildtool/common/protocol_traits.hpp index 49850233..f1a51cbe 100644 --- a/src/buildtool/common/protocol_traits.hpp +++ b/src/buildtool/common/protocol_traits.hpp @@ -15,6 +15,8 @@ #ifndef INCLUDED_SRC_BUILDTOOL_COMMON_PROTOCOL_TRAITS_HPP #define INCLUDED_SRC_BUILDTOOL_COMMON_PROTOCOL_TRAITS_HPP +#include "src/buildtool/crypto/hash_function.hpp" + class ProtocolTraits final { public: [[nodiscard]] static auto Instance() noexcept -> ProtocolTraits& { @@ -26,6 +28,16 @@ class ProtocolTraits final { } void SetCompatible(bool value = true) noexcept { compatible_ = value; } + inline static constexpr auto IsNative(HashFunction::Type hash_type) noexcept + -> bool { + return hash_type == HashFunction::Type::GitSHA1; + } + + inline static constexpr auto IsTreeAllowed( + HashFunction::Type hash_type) noexcept -> bool { + return IsNative(hash_type); + } + private: bool compatible_ = false; }; -- cgit v1.2.3