diff options
author | Kasper Gałkowski <kpg@posteo.net> | 2022-04-08 19:38:43 +0200 |
---|---|---|
committer | Kasper Gałkowski <kpg@posteo.net> | 2022-04-12 21:13:14 +0200 |
commit | 2769e43f61d827e1b8fe46257450986d76319243 (patch) | |
tree | 204ee0a1ac88f41e03cbff14d9e50c4f43e69a4a /src/libfetchers/mercurial.cc | |
parent | 2c2fd4946f96e6839ecbfb4cf61318d8910e7e8f (diff) |
assert hash types for Git and Mercurial
Diffstat (limited to 'src/libfetchers/mercurial.cc')
-rw-r--r-- | src/libfetchers/mercurial.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libfetchers/mercurial.cc b/src/libfetchers/mercurial.cc index 8b82e9daa..19ff98030 100644 --- a/src/libfetchers/mercurial.cc +++ b/src/libfetchers/mercurial.cc @@ -201,8 +201,17 @@ struct MercurialInputScheme : InputScheme if (!input.getRef()) input.attrs.insert_or_assign("ref", "default"); + auto checkHashType = [&](const std::optional<Hash> & hash) + { + if (hash.has_value() && hash->type != htSHA1) + throw Error("Hash '%s' is not supported by Mercurial. Only sha1 is supported.", hash->to_string(Base16, true)); + }; + + auto getLockedAttrs = [&]() { + checkHashType(input.getRev()); + return Attrs({ {"type", "hg"}, {"name", name}, |