From 1d6c7d66505debebd6bdc5877d45f8833c4616b5 Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Fri, 14 Nov 2025 13:27:51 +0800 Subject: [PATCH] fetchgit: move assertions down to argument values --- pkgs/build-support/fetchgit/default.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index 5a8ea3cf0488..4d0c2c7af8b1 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -128,10 +128,6 @@ lib.makeOverridable ( server admins start using the new version? */ - assert nonConeMode -> (sparseCheckout != [ ]); - assert fetchTags -> leaveDotGit; - assert rootDir != "" -> !leaveDotGit; - if builtins.isString sparseCheckout then # Changed to throw on 2023-06-04 throw @@ -154,14 +150,15 @@ lib.makeOverridable ( inherit outputHash outputHashAlgo; outputHashMode = "recursive"; - # git-sparse-checkout(1) says: - # > 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. - sparseCheckout = builtins.concatStringsSep "\n" sparseCheckout; + sparseCheckout = + assert nonConeMode -> (sparseCheckout != [ ]); + # git-sparse-checkout(1) says: + # > 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. + builtins.concatStringsSep "\n" sparseCheckout; inherit url - leaveDotGit fetchLFS fetchSubmodules deepClone @@ -173,6 +170,10 @@ lib.makeOverridable ( rootDir gitConfigFile ; + leaveDotGit = + assert fetchTags -> leaveDotGit; + assert rootDir != "" -> !leaveDotGit; + leaveDotGit; inherit tag; revCustom = rev; rev = getRevWithTag {