mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Merge pull request #14205 from GrahamDennis/gdennis/improve-dir-url-backcompat
Improved backwards compatibility hack for git URLs using dir=...
This commit is contained in:
commit
5700112127
1 changed files with 30 additions and 0 deletions
|
|
@ -496,6 +496,36 @@ struct GitInputScheme : InputScheme
|
||||||
Git interprets them as part of the file name. So get
|
Git interprets them as part of the file name. So get
|
||||||
rid of them. */
|
rid of them. */
|
||||||
url.query.clear();
|
url.query.clear();
|
||||||
|
/* Backward compatibility hack: In old versions of Nix, if you had
|
||||||
|
a flake input like
|
||||||
|
|
||||||
|
inputs.foo.url = "git+https://foo/bar?dir=subdir";
|
||||||
|
|
||||||
|
it would result in a lock file entry like
|
||||||
|
|
||||||
|
"original": {
|
||||||
|
"dir": "subdir",
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://foo/bar?dir=subdir"
|
||||||
|
}
|
||||||
|
|
||||||
|
New versions of Nix remove `?dir=subdir` from the `url` field,
|
||||||
|
since the subdirectory is intended for `FlakeRef`, not the
|
||||||
|
fetcher (and specifically the remote server), that is, the
|
||||||
|
flakeref is parsed into
|
||||||
|
|
||||||
|
"original": {
|
||||||
|
"dir": "subdir",
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://foo/bar"
|
||||||
|
}
|
||||||
|
|
||||||
|
However, new versions of nix parsing old flake.lock files would pass the dir=
|
||||||
|
query parameter in the "url" attribute to git, which will then complain.
|
||||||
|
|
||||||
|
For this reason, we are filtering the `dir` query parameter from the URL
|
||||||
|
before passing it to git. */
|
||||||
|
url.query.erase("dir");
|
||||||
repoInfo.location = url;
|
repoInfo.location = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue