importCargoLock: git deps with rev, branch or tag
Previously importCargoLog only recognized git dependencies with `rev =`. This adds support for git dependencies with `branch =` or `tag =`.
This commit is contained in:
parent
91a4081ce4
commit
00b1ac5b23
1 changed files with 6 additions and 5 deletions
|
@ -12,14 +12,15 @@ let
|
||||||
# Parse a git source into different components.
|
# Parse a git source into different components.
|
||||||
parseGit = src:
|
parseGit = src:
|
||||||
let
|
let
|
||||||
parts = builtins.match ''git\+([^?]+)(\?rev=(.*))?#(.*)?'' src;
|
parts = builtins.match ''git\+([^?]+)(\?(rev|tag|branch)=(.*))?#(.*)'' src;
|
||||||
rev = builtins.elemAt parts 2;
|
type = builtins.elemAt parts 2; # rev, tag or branch
|
||||||
|
value = builtins.elemAt parts 3;
|
||||||
in
|
in
|
||||||
if parts == null then null
|
if parts == null then null
|
||||||
else {
|
else {
|
||||||
url = builtins.elemAt parts 0;
|
url = builtins.elemAt parts 0;
|
||||||
sha = builtins.elemAt parts 3;
|
sha = builtins.elemAt parts 4;
|
||||||
} // lib.optionalAttrs (rev != null) { inherit rev; };
|
} // lib.optionalAttrs (type != null) { inherit type value; };
|
||||||
|
|
||||||
packages = (builtins.fromTOML (builtins.readFile lockFile)).package;
|
packages = (builtins.fromTOML (builtins.readFile lockFile)).package;
|
||||||
|
|
||||||
|
@ -137,7 +138,7 @@ let
|
||||||
cat > $out/.cargo-config <<EOF
|
cat > $out/.cargo-config <<EOF
|
||||||
[source."${gitParts.url}"]
|
[source."${gitParts.url}"]
|
||||||
git = "${gitParts.url}"
|
git = "${gitParts.url}"
|
||||||
${lib.optionalString (gitParts ? rev) "rev = \"${gitParts.rev}\""}
|
${lib.optionalString (gitParts ? type) "${gitParts.type} = \"${gitParts.value}\""}
|
||||||
replace-with = "vendored-sources"
|
replace-with = "vendored-sources"
|
||||||
EOF
|
EOF
|
||||||
''
|
''
|
||||||
|
|
Loading…
Reference in a new issue