summaryrefslogtreecommitdiff
path: root/src/buildtool/crypto/hash_info.cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-11 10:21:13 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-13 14:41:00 +0200
commitddf48a60029bed958fb2cf0238dbb0bca0b770fb (patch)
tree6c42568d14624a36a4f9b07d578d2a001764065d /src/buildtool/crypto/hash_info.cpp
parentf60d39620b29aeaf1addeb244bdd6e15ddf4894c (diff)
downloadjustbuild-ddf48a60029bed958fb2cf0238dbb0bca0b770fb.tar.gz
Add to ProtocolTraits static functions that provide protocol-specific behaviour
Diffstat (limited to 'src/buildtool/crypto/hash_info.cpp')
-rw-r--r--src/buildtool/crypto/hash_info.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/buildtool/crypto/hash_info.cpp b/src/buildtool/crypto/hash_info.cpp
index 3b14d445..4fb87161 100644
--- a/src/buildtool/crypto/hash_info.cpp
+++ b/src/buildtool/crypto/hash_info.cpp
@@ -16,6 +16,7 @@
#include "fmt/core.h"
#include "gsl/gsl" // Ensures
+#include "src/buildtool/common/protocol_traits.hpp"
#include "src/buildtool/crypto/hasher.hpp"
#include "src/utils/cpp/hex_string.hpp"
@@ -58,7 +59,7 @@ auto HashInfo::HashData(HashFunction hash_function,
return HashInfo{
hash_digest.HexString(),
hash_function.GetType(),
- is_tree and hash_function.GetType() == HashFunction::Type::GitSHA1};
+ is_tree and ProtocolTraits::IsTreeAllowed(hash_function.GetType())};
}
auto HashInfo::HashFile(HashFunction hash_function,
@@ -85,7 +86,7 @@ auto HashInfo::ValidateInput(HashFunction::Type type,
std::string const& hash,
bool is_tree) noexcept
-> std::optional<std::string> {
- if (type != HashFunction::Type::GitSHA1 and is_tree) {
+ if (is_tree and not ProtocolTraits::IsTreeAllowed(type)) {
return fmt::format(
"HashInfo: hash {} is expected to be {}.\nTrees are "
"not allowed in this mode.",