From 8fc1c3f413c20b4519a41e38365aa71fa06a5aae Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 8 May 2019 22:08:38 +0200 Subject: [PATCH] Fix assertion failure in FlakeRef::to_string() Fixes $ nix build nix: src/libexpr/primops/flakeref.cc:169: std::__cxx11::string nix::FlakeRef::to_string() const: Assertion `!rev' failed. Aborted e.g. when flake.nix doesn't exist. Also use gitRev(). --- src/libexpr/primops/flakeref.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libexpr/primops/flakeref.cc b/src/libexpr/primops/flakeref.cc index 784a0868e..3842b3f1a 100644 --- a/src/libexpr/primops/flakeref.cc +++ b/src/libexpr/primops/flakeref.cc @@ -161,13 +161,13 @@ std::string FlakeRef::to_string() const if (auto refData = std::get_if(&data)) { string = refData->alias; if (ref) string += '/' + *ref; - if (rev) string += '/' + rev->to_string(Base16, false); + if (rev) string += '/' + rev->gitRev(); } else if (auto refData = std::get_if(&data)) { assert(subdir == ""); - assert(!rev); - assert(!ref); + if (ref) addParam("ref", *ref); + if (rev) addParam("rev", rev->gitRev()); return refData->path; } @@ -175,7 +175,7 @@ std::string FlakeRef::to_string() const assert(!(ref && rev)); string = "github:" + refData->owner + "/" + refData->repo; if (ref) { string += '/'; string += *ref; } - if (rev) { string += '/'; string += rev->to_string(Base16, false); } + if (rev) { string += '/'; string += rev->gitRev(); } if (subdir != "") addParam("dir", subdir); } @@ -186,7 +186,7 @@ std::string FlakeRef::to_string() const if (ref) { addParam("ref", *ref); if (rev) - addParam("rev", rev->to_string(Base16, false)); + addParam("rev", rev->gitRev()); } if (subdir != "") addParam("dir", subdir);