diff --git a/lix/libfetchers/github.cc b/lix/libfetchers/github.cc index 4b36c066c..7a4362c68 100644 --- a/lix/libfetchers/github.cc +++ b/lix/libfetchers/github.cc @@ -150,8 +150,15 @@ struct GitArchiveInputScheme : InputScheme auto ref = input.getRef(); auto rev = input.getRev(); auto path = owner + "/" + repo; - assert(!(ref && rev)); - if (ref) path += "/" + *ref; + if (ref && rev) { + throw Error( + "input '%s:%s/%s' has both ref (%s) and rev (%s), which is not allowed", + schemeType(), owner, repo, *ref, rev->gitRev() + ); + } + if (ref) { + path += "/" + *ref; + } if (rev) { path += "/" + rev->to_string(HashFormat::Base16, false); } diff --git a/tests/functional2/lang/builtins.fetchtree/eval-fail-github-ref-rev.err.exp b/tests/functional2/lang/builtins.fetchtree/eval-fail-github-ref-rev.err.exp new file mode 100644 index 000000000..264342eb9 --- /dev/null +++ b/tests/functional2/lang/builtins.fetchtree/eval-fail-github-ref-rev.err.exp @@ -0,0 +1,9 @@ +error: + … while calling the 'fetchTree' builtin + at /pwd/in.nix:3:1: + 2| # https://git.lix.systems/lix-project/lix/issues/1133 + 3| builtins.fetchTree { + | ^ + 4| type = "github"; + + error: input 'github:nixos/nixpkgs' has both ref (nixpkgs-unstable) and rev (e4bae1bd10c9c57b2cf517953ab70060a828ee6f), which is not allowed diff --git a/tests/functional2/lang/builtins.fetchtree/in-github-ref-rev.nix b/tests/functional2/lang/builtins.fetchtree/in-github-ref-rev.nix new file mode 100644 index 000000000..eb381dce0 --- /dev/null +++ b/tests/functional2/lang/builtins.fetchtree/in-github-ref-rev.nix @@ -0,0 +1,9 @@ +# tests that this produces a proper error, as it didn't before +# https://git.lix.systems/lix-project/lix/issues/1133 +builtins.fetchTree { + type = "github"; + owner = "nixos"; + repo = "nixpkgs"; + ref = "nixpkgs-unstable"; + rev = "e4bae1bd10c9c57b2cf517953ab70060a828ee6f"; +}