fetchgit: add preFetch hook (#404488)

authored by philiptaron.tngl.sh and committed by

GitHub 3fd3d5bc 5eefa703

+14 -2
+6 -1
doc/build-helpers/fetchers.chapter.md
··· 773 773 774 774 : Whether to fetch LFS objects. 775 775 776 + *`preFetch`* (String) 777 + 778 + : Shell code to be executed before the repository has been fetched, to allow 779 + changing the environment the fetcher runs in. 780 + 776 781 *`postFetch`* (String) 777 782 778 - : Shell code executed after the file has been fetched successfully. 783 + : Shell code executed after the repository has been fetched successfully. 779 784 This can do things like check or transform the file. 780 785 781 786 *`leaveDotGit`* (Boolean)
+2
pkgs/build-support/fetchgit/builder.sh
··· 6 6 7 7 echo "exporting $url (rev $rev) into $out" 8 8 9 + runHook preFetch 10 + 9 11 $SHELL $fetcher --builder --url "$url" --out "$out" --rev "$rev" --name "$name" \ 10 12 ${leaveDotGit:+--leave-dotGit} \ 11 13 ${fetchLFS:+--fetch-lfs} \
+6 -1
pkgs/build-support/fetchgit/default.nix
··· 38 38 nonConeMode ? false, 39 39 name ? null, 40 40 nativeBuildInputs ? [ ], 41 + # Shell code executed before the file has been fetched. This, in 42 + # particular, can do things like set NIX_PREFETCH_GIT_CHECKOUT_HOOK to 43 + # run operations between the checkout completing and deleting the .git 44 + # directory. 45 + preFetch ? "", 41 46 # Shell code executed after the file has been fetched 42 47 # successfully. This can do things like check or transform the file. 43 48 postFetch ? "", ··· 75 80 server admins start using the new version? 76 81 */ 77 82 78 - assert deepClone -> leaveDotGit; 79 83 assert nonConeMode -> (sparseCheckout != [ ]); 80 84 81 85 let ··· 130 134 deepClone 131 135 branchName 132 136 nonConeMode 137 + preFetch 133 138 postFetch 134 139 ; 135 140 rev = revWithTag;