fetchgit: require sparseCheckout be a list of strings

Passing a (multi-line) string was deprecated in #200082 in favour of
list of strings, but still supported (with warning). Now, enforce use of
list of strings.
This commit is contained in:
Nicolas Benes 2023-06-04 10:04:31 +02:00
parent ac3ad2b757
commit 52f3a1c42c
2 changed files with 6 additions and 6 deletions

View file

@ -54,16 +54,16 @@ lib.makeOverridable (
*/ */
assert deepClone -> leaveDotGit; assert deepClone -> leaveDotGit;
assert nonConeMode -> !(sparseCheckout == "" || sparseCheckout == []); assert nonConeMode -> (sparseCheckout != []);
if md5 != "" then if md5 != "" then
throw "fetchgit does not support md5 anymore, please use sha256" throw "fetchgit does not support md5 anymore, please use sha256"
else if hash != "" && sha256 != "" then else if hash != "" && sha256 != "" then
throw "Only one of sha256 or hash can be set" throw "Only one of sha256 or hash can be set"
else if builtins.isString sparseCheckout then
# Changed to throw on 2023-06-04
throw "Please provide directories/patterns for sparse checkout as a list of strings. Passing a (multi-line) string is not supported any more."
else else
# Added 2022-11-12
lib.warnIf (builtins.isString sparseCheckout)
"Please provide directories/patterns for sparse checkout as a list of strings. Support for passing a (multi-line) string is deprecated and will be removed in the next release."
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {
inherit name; inherit name;
builder = ./builder.sh; builder = ./builder.sh;
@ -84,7 +84,7 @@ stdenvNoCC.mkDerivation {
# git-sparse-checkout(1) says: # git-sparse-checkout(1) says:
# > When the --stdin option is provided, the directories or patterns are read # > When the --stdin option is provided, the directories or patterns are read
# > from standard in as a newline-delimited list instead of from the arguments. # > from standard in as a newline-delimited list instead of from the arguments.
sparseCheckout = if builtins.isString sparseCheckout then sparseCheckout else builtins.concatStringsSep "\n" sparseCheckout; sparseCheckout = builtins.concatStringsSep "\n" sparseCheckout;
inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName nonConeMode postFetch; inherit url rev leaveDotGit fetchLFS fetchSubmodules deepClone branchName nonConeMode postFetch;

View file

@ -25,7 +25,7 @@ let
}; };
passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "forceFetchGit" "private" "githubBase" "varPrefix" ]; passthruAttrs = removeAttrs args [ "owner" "repo" "rev" "fetchSubmodules" "forceFetchGit" "private" "githubBase" "varPrefix" ];
varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_"; varBase = "NIX${if varPrefix == null then "" else "_${varPrefix}"}_GITHUB_PRIVATE_";
useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || !(sparseCheckout == "" || sparseCheckout == []); useFetchGit = fetchSubmodules || (leaveDotGit == true) || deepClone || forceFetchGit || (sparseCheckout != []);
# We prefer fetchzip in cases we don't need submodules as the hash # We prefer fetchzip in cases we don't need submodules as the hash
# is more stable in that case. # is more stable in that case.
fetcher = if useFetchGit then fetchgit else fetchzip; fetcher = if useFetchGit then fetchgit else fetchzip;