From 88b44b1e94735710853bdabb6904073bc77f2ccb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 29 Jan 2020 22:53:03 +0100 Subject: [PATCH] Fix flake update check --- src/libexpr/flake/flake.cc | 4 +++- src/libstore/fetchers/git.cc | 5 ++++- src/libstore/fetchers/mercurial.cc | 5 ++++- src/libstore/fetchers/parse.cc | 10 ++++++++++ src/libstore/fetchers/parse.hh | 2 ++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index f255f99e2..c752eeedc 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -280,11 +280,13 @@ static std::string diffLockFiles(const LockedInputs & oldLocks, const LockedInpu res += fmt(" removed '%s'\n", concatStringsSep("/", i->first)); ++i; } else { - if (!(i->second->ref == j->second->ref)) + if (!(i->second->ref == j->second->ref)) { + assert(i->second->ref.to_string() != j->second->ref.to_string()); res += fmt(" updated '%s': '%s' -> '%s'\n", concatStringsSep("/", i->first), i->second->ref, j->second->ref); + } ++i; ++j; } diff --git a/src/libstore/fetchers/git.cc b/src/libstore/fetchers/git.cc index 16bbcd285..1350c5754 100644 --- a/src/libstore/fetchers/git.cc +++ b/src/libstore/fetchers/git.cc @@ -83,7 +83,7 @@ struct GitInput : Input auto other2 = dynamic_cast(&other); return other2 - && url.url == other2->url.url + && url == other2->url && rev == other2->rev && ref == other2->ref; } @@ -361,6 +361,8 @@ struct GitInputScheme : InputScheme auto input = std::make_unique(url); + input->url.query.clear(); + for (auto &[name, value] : url.query) { if (name == "rev") { if (!std::regex_match(value, revRegex)) @@ -372,6 +374,7 @@ struct GitInputScheme : InputScheme throw BadURL("Git URL '%s' contains an invalid branch/tag name", url.url); input->ref = value; } + else input->url.query.insert_or_assign(name, value); } return input; diff --git a/src/libstore/fetchers/mercurial.cc b/src/libstore/fetchers/mercurial.cc index e6f252700..e012f98fc 100644 --- a/src/libstore/fetchers/mercurial.cc +++ b/src/libstore/fetchers/mercurial.cc @@ -29,7 +29,7 @@ struct MercurialInput : Input auto other2 = dynamic_cast(&other); return other2 - && url.url == other2->url.url + && url == other2->url && rev == other2->rev && ref == other2->ref; } @@ -255,6 +255,8 @@ struct MercurialInputScheme : InputScheme auto input = std::make_unique(url); + input->url.query.clear(); + for (auto &[name, value] : url.query) { if (name == "rev") { if (!std::regex_match(value, revRegex)) @@ -266,6 +268,7 @@ struct MercurialInputScheme : InputScheme throw BadURL("Mercurial URL '%s' contains an invalid branch/tag name", url.url); input->ref = value; } + else input->url.query.insert_or_assign(name, value); } return input; diff --git a/src/libstore/fetchers/parse.cc b/src/libstore/fetchers/parse.cc index 88c2844d0..dc1b3efe6 100644 --- a/src/libstore/fetchers/parse.cc +++ b/src/libstore/fetchers/parse.cc @@ -127,4 +127,14 @@ std::string ParsedURL::to_string() const + (fragment.empty() ? "" : "#" + percentEncode(fragment)); } +bool ParsedURL::operator ==(const ParsedURL & other) const +{ + return + scheme == other.scheme + && authority == other.authority + && path == other.path + && query == other.query + && fragment == other.fragment; +} + } diff --git a/src/libstore/fetchers/parse.hh b/src/libstore/fetchers/parse.hh index 22cc57816..45d5182b0 100644 --- a/src/libstore/fetchers/parse.hh +++ b/src/libstore/fetchers/parse.hh @@ -15,6 +15,8 @@ struct ParsedURL std::string fragment; std::string to_string() const; + + bool operator ==(const ParsedURL & other) const; }; MakeError(BadURL, Error);