mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
Merge pull request #268304 from panicgh/fetchgitlab-sparse-forcegit
fetchgitlab: add sparseCheckout and forceFetchGit args
This commit is contained in:
commit
adc2612d49
@ -1,9 +1,11 @@
|
|||||||
{ fetchgit, fetchzip, lib }:
|
{ lib, fetchgit, fetchzip }:
|
||||||
|
|
||||||
lib.makeOverridable (
|
lib.makeOverridable (
|
||||||
# gitlab example
|
# gitlab example
|
||||||
{ owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null
|
{ owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null
|
||||||
, fetchSubmodules ? false, leaveDotGit ? false, deepClone ? false
|
, fetchSubmodules ? false, leaveDotGit ? false
|
||||||
|
, deepClone ? false, forceFetchGit ? false
|
||||||
|
, sparseCheckout ? []
|
||||||
, ... # For hash agility
|
, ... # For hash agility
|
||||||
} @ args:
|
} @ args:
|
||||||
|
|
||||||
@ -11,15 +13,15 @@ let
|
|||||||
slug = lib.concatStringsSep "/" ((lib.optional (group != null) group) ++ [ owner repo ]);
|
slug = lib.concatStringsSep "/" ((lib.optional (group != null) group) ++ [ owner repo ]);
|
||||||
escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug;
|
escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug;
|
||||||
escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev;
|
escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev;
|
||||||
passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "leaveDotGit" "deepClone" ];
|
passthruAttrs = removeAttrs args [ "protocol" "domain" "owner" "group" "repo" "rev" "fetchSubmodules" "forceFetchGit" "leaveDotGit" "deepClone" ];
|
||||||
|
|
||||||
useFetchGit = deepClone || fetchSubmodules || leaveDotGit;
|
useFetchGit = fetchSubmodules || leaveDotGit || deepClone || forceFetchGit || (sparseCheckout != []);
|
||||||
fetcher = if useFetchGit then fetchgit else fetchzip;
|
fetcher = if useFetchGit then fetchgit else fetchzip;
|
||||||
|
|
||||||
gitRepoUrl = "${protocol}://${domain}/${slug}.git";
|
gitRepoUrl = "${protocol}://${domain}/${slug}.git";
|
||||||
|
|
||||||
fetcherArgs = (if useFetchGit then {
|
fetcherArgs = (if useFetchGit then {
|
||||||
inherit rev deepClone fetchSubmodules leaveDotGit;
|
inherit rev deepClone fetchSubmodules sparseCheckout leaveDotGit;
|
||||||
url = gitRepoUrl;
|
url = gitRepoUrl;
|
||||||
} else {
|
} else {
|
||||||
url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
|
url = "${protocol}://${domain}/api/v4/projects/${escapedSlug}/repository/archive.tar.gz?sha=${escapedRev}";
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
# the rest are given to fetchurl as is
|
# the rest are given to fetchurl as is
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
|
|
||||||
assert (extraPostFetch != "") -> lib.warn "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'." true;
|
assert (extraPostFetch != "") -> lib.warn "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub' or 'fetchFromGitLab'." true;
|
||||||
|
|
||||||
let
|
let
|
||||||
tmpFilename =
|
tmpFilename =
|
||||||
|
Loading…
Reference in New Issue
Block a user