fetchgitlab: add option for sparse checkout

This commit is contained in:
Nicolas Benes 2023-11-18 13:14:08 +01:00
parent 9375cf2008
commit a838881cda

View file

@ -5,6 +5,7 @@ lib.makeOverridable (
{ owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null
, fetchSubmodules ? false, leaveDotGit ? false
, deepClone ? false
, sparseCheckout ? []
, ... # For hash agility
} @ args:
@ -14,13 +15,13 @@ let
escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev;
passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "leaveDotGit" "deepClone" ];
useFetchGit = fetchSubmodules || leaveDotGit || deepClone;
useFetchGit = fetchSubmodules || leaveDotGit || deepClone || (sparseCheckout != []);
fetcher = if useFetchGit then fetchgit else fetchzip;
gitRepoUrl = "${protocol}://${domain}/${slug}.git";
fetcherArgs = (if useFetchGit then {
inherit rev deepClone fetchSubmodules leaveDotGit;
inherit rev deepClone fetchSubmodules sparseCheckout leaveDotGit;
url = gitRepoUrl;
} else {
url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";