Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchgit: shallow clone for submodules #254172

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkgs/build-support/fetchgit/nix-prefetch-git
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ checkout_ref(){

# Update submodules
init_submodules(){
# shallow with leaveDotGit will change hashes
[[ -z "$deepClone" ]] && [[ -z "$leaveDotGit" ]] && \
clean_git submodule update --init --recursive -j ${NIX_BUILD_CORES:-1} --progress --depth 1 || \
pineapplehunter marked this conversation as resolved.
Show resolved Hide resolved
clean_git submodule update --init --recursive -j ${NIX_BUILD_CORES:-1} --progress
}

Expand Down
54 changes: 48 additions & 6 deletions pkgs/build-support/fetchgit/tests.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{ testers, fetchgit, ... }:

{
{ testers, fetchgit, ... }: {
simple = testers.invalidateFetcherByDrvHash fetchgit {
name = "nix-source";
name = "simple-nix-source";
url = "https://github.com/NixOS/nix";
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
sha256 = "sha256-7DszvbCNTjpzGRmpIVAWXk20P0/XTrWZ79KSOGLrUWY=";
};

sparseCheckout = testers.invalidateFetcherByDrvHash fetchgit {
name = "nix-source";
name = "sparse-checkout-nix-source";
url = "https://github.com/NixOS/nix";
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
sparseCheckout = [
Expand All @@ -20,7 +18,7 @@
};

sparseCheckoutNonConeMode = testers.invalidateFetcherByDrvHash fetchgit {
name = "nix-source";
name = "sparse-checkout-non-cone-nix-source";
url = "https://github.com/NixOS/nix";
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
sparseCheckout = [
Expand All @@ -30,4 +28,48 @@
nonConeMode = true;
sha256 = "sha256-FknO6C/PSnMPfhUqObD4vsW4PhkwdmPa9blNzcNvJQ4=";
};

leave-git = testers.invalidateFetcherByDrvHash fetchgit {
name = "leave-git-nix-source";
url = "https://github.com/NixOS/nix";
rev = "9d9dbe6ed05854e03811c361a3380e09183f4f4a";
sha256 = "sha256-zZxDxqaeWvuWuzwPizBLR7d59zP24+zqnWllNICenko=";
leaveDotGit = true;
};

submodule-simple = testers.invalidateFetcherByDrvHash fetchgit {
name = "submodule-simple-source";
url = "https://github.com/pineapplehunter/nix-test-repo-with-submodule";
rev = "26473335b84ead88ee0a3b649b1c7fa4a91cfd4a";
sha256 = "sha256-rmP8PQT0wJBopdtr/hsB7Y/L1G+ZPdHC2r9LB05Qrj4=";
fetchSubmodules = true;
};

submodule-leave-git = testers.invalidateFetcherByDrvHash fetchgit {
name = "submodule-leave-git-source";
url = "https://github.com/pineapplehunter/nix-test-repo-with-submodule";
rev = "26473335b84ead88ee0a3b649b1c7fa4a91cfd4a";
sha256 = "sha256-+uXIClcRJ4S1rdgx2Oyww+Jv4h1VXp8tfeh9lb07Fhk=";
leaveDotGit = true;
fetchSubmodules = true;
};

submodule-deep = testers.invalidateFetcherByDrvHash fetchgit {
name = "submodule-deep-source";
url = "https://github.com/pineapplehunter/nix-test-repo-with-submodule";
rev = "26473335b84ead88ee0a3b649b1c7fa4a91cfd4a";
sha256 = "sha256-LL7uhXQk3N3DcvBBxwjmfVx55tTXCGQ19T91tknopzw=";
deepClone = true;
fetchSubmodules = true;
};

submodule-leave-git-deep = testers.invalidateFetcherByDrvHash fetchgit {
name = "submodule-leave-git-deep-source";
url = "https://github.com/pineapplehunter/nix-test-repo-with-submodule";
rev = "26473335b84ead88ee0a3b649b1c7fa4a91cfd4a";
sha256 = "sha256-LL7uhXQk3N3DcvBBxwjmfVx55tTXCGQ19T91tknopzw=";
deepClone = true;
leaveDotGit = true;
fetchSubmodules = true;
};
}