mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
fetchgitlab: add deepClone, fetchSubmodules, leaveDotGit arguments
This commit is contained in:
parent
94675cc77a
commit
94848bd430
@ -1,22 +1,26 @@
|
|||||||
{ fetchzip, lib }:
|
{ fetchgit, fetchzip, lib }:
|
||||||
|
|
||||||
# gitlab example
|
# gitlab example
|
||||||
{ owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null
|
{ owner, repo, rev, domain ? "gitlab.com", name ? "source", group ? null
|
||||||
|
, fetchSubmodules ? false, leaveDotGit ? false, deepClone ? false
|
||||||
, ... # For hash agility
|
, ... # For hash agility
|
||||||
} @ args:
|
} @ args:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
slug = concatStringsSep "/"
|
slug = lib.concatStringsSep "/" ((lib.optional (group != null) group) ++ [ owner repo ]);
|
||||||
((optional (group != null) group) ++ [ owner repo ]);
|
escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug;
|
||||||
|
escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev;
|
||||||
|
passthruAttrs = removeAttrs args [ "domain" "owner" "group" "repo" "rev" ];
|
||||||
|
|
||||||
escapedSlug = replaceStrings ["." "/"] ["%2E" "%2F"] slug;
|
useFetchGit = deepClone || fetchSubmodules || leaveDotGit;
|
||||||
escapedRev = replaceStrings ["+" "%" "/"] ["%2B" "%25" "%2F"] rev;
|
fetcher = if useFetchGit then fetchgit else fetchzip;
|
||||||
|
|
||||||
|
fetcherArgs = (if useFetchGit then {
|
||||||
|
inherit rev deepClone fetchSubmodules leaveDotGit;
|
||||||
|
url = "https://${domain}/${slug}.git";
|
||||||
|
} else {
|
||||||
|
url = "https://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
|
||||||
|
}) // passthruAttrs // { inherit name; };
|
||||||
in
|
in
|
||||||
|
|
||||||
fetchzip ({
|
fetcher fetcherArgs // { meta.homepage = "https://${domain}/${slug}/"; inherit rev; }
|
||||||
inherit name;
|
|
||||||
url = "https://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
|
|
||||||
meta.homepage = "https://${domain}/${slug}/";
|
|
||||||
} // removeAttrs args [ "domain" "owner" "group" "repo" "rev" ]) // { inherit rev; }
|
|
||||||
|
Loading…
Reference in New Issue
Block a user