From 6cfc2db49424c63b7ca6b837e8a4cb7bf373c01b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 9 Jun 2020 13:45:07 +0200 Subject: [PATCH] Fix applyOverride() for github --- src/libexpr/flake/flake.cc | 2 +- src/libfetchers/fetchers.cc | 1 + src/libfetchers/github.cc | 8 +++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index c94924371..5f021192b 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -57,7 +57,7 @@ static std::tuple fetchOrSubstituteTree( } flakeCache.push_back({originalRef, fetched.value()}); } - + auto [tree, lockedRef] = fetched.value(); debug("got tree '%s' from '%s'", diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc index 067db5e2e..d808aadd6 100644 --- a/src/libfetchers/fetchers.cc +++ b/src/libfetchers/fetchers.cc @@ -91,6 +91,7 @@ bool Input::operator ==(const Input & other) const bool Input::contains(const Input & other) const { + if (*this == other) return true; auto other2(other); other2.attrs.erase("ref"); other2.attrs.erase("rev"); diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc index e704592f7..8dc9cb4bf 100644 --- a/src/libfetchers/github.cc +++ b/src/libfetchers/github.cc @@ -59,7 +59,7 @@ struct GitArchiveInputScheme : InputScheme } if (ref && rev) - throw BadURL("URL '%s' contains both a commit hash and a branch/tag name", url.url); + throw BadURL("URL '%s' contains both a commit hash and a branch/tag name %s %s", url.url, *ref, rev->gitRev()); Input input; input.attrs.insert_or_assign("type", type()); @@ -115,14 +115,16 @@ struct GitArchiveInputScheme : InputScheme std::optional rev) override { auto input(_input); + if (rev && ref) + throw BadURL("cannot apply both a commit hash (%s) and a branch/tag name ('%s') to input '%s'", + rev->gitRev(), *ref, input.to_string()); if (rev) { input.attrs.insert_or_assign("rev", rev->gitRev()); input.attrs.erase("ref"); } if (ref) { - if (input.getRev()) - throw BadURL("input '%s' contains both a commit hash and a branch/tag name", input.to_string()); input.attrs.insert_or_assign("ref", *ref); + input.attrs.erase("rev"); } return input; }