Merge pull request #11933 from DeterminateSystems/no-narHash

fetchTree: Don't crash if narHash is missing
This commit is contained in:
Jörg Thalheim 2024-11-22 08:07:50 +01:00 committed by GitHub
commit 838d3c1ad0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,9 +33,8 @@ void emitTreeAttrs(
// FIXME: support arbitrary input attributes.
auto narHash = input.getNarHash();
assert(narHash);
attrs.alloc("narHash").mkString(narHash->to_string(HashFormat::SRI, true));
if (auto narHash = input.getNarHash())
attrs.alloc("narHash").mkString(narHash->to_string(HashFormat::SRI, true));
if (input.getType() == "git")
attrs.alloc("submodules").mkBool(