aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers/fetchers.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libfetchers/fetchers.cc')
-rw-r--r--src/libfetchers/fetchers.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc
index 4c457966d..2a1529a60 100644
--- a/src/libfetchers/fetchers.cc
+++ b/src/libfetchers/fetchers.cc
@@ -244,9 +244,18 @@ std::optional<std::string> Input::getRef() const
std::optional<Hash> Input::getRev() const
{
- if (auto s = maybeGetStrAttr(attrs, "rev"))
- return Hash::parseAny(*s, htSHA1);
- return {};
+ std::optional<Hash> hash = {};
+
+ if (auto s = maybeGetStrAttr(attrs, "rev")) {
+ try {
+ hash = Hash::parseAnyPrefixed(*s);
+ } catch (BadHash &e) {
+ // Default to sha1 for backwards compatibility with existing flakes
+ hash = Hash::parseAny(*s, htSHA1);
+ }
+ }
+
+ return hash;
}
std::optional<uint64_t> Input::getRevCount() const