fetchFromGitHub: use fetchgit when the rootDir option is set

This argument was added to fetchgit in #427165,
and it's not supported by fetchzip.

Co-authored-by: Philip Taron <philip.taron@gmail.com>
This commit is contained in:
Michael Daniels
2025-09-27 12:38:29 -04:00
parent 638e1bf59b
commit 42637c305f
2 changed files with 11 additions and 2 deletions

View File

@@ -860,7 +860,14 @@ A number of fetcher functions wrap part of `fetchurl` and `fetchzip`. They are m
To use a different GitHub instance, use `githubBase` (defaults to `"github.com"`).
`fetchFromGitHub` uses `fetchzip` to download the source archive generated by GitHub for the specified revision. If `leaveDotGit`, `deepClone` or `fetchSubmodules` are set to `true`, `fetchFromGitHub` will use `fetchgit` instead. Refer to its section for documentation of these options.
By default, `fetchFromGitHub` uses `fetchzip` to download GitHub's source archive for the specified revision.
However, `fetchFromGitHub` will automatically switch to using `fetchgit` in any of these cases:
- `forceFetchGit`, `leaveDotGit`, `deepClone`, `fetchLFS`, or `fetchSubmodules` are set to `true`
- `sparseCheckout` contains any entries (is a non-empty list)
- `rootDir` is set to a non-empty string
When `fetchgit` is used, refer to the `fetchgit` section for documentation of its available options.
## `fetchFromGitLab` {#fetchfromgitlab}

View File

@@ -18,7 +18,8 @@ lib.makeOverridable (
private ? false,
forceFetchGit ? false,
fetchLFS ? false,
sparseCheckout ? [ ],
rootDir ? "",
sparseCheckout ? lib.optional (rootDir != "") rootDir,
githubBase ? "github.com",
varPrefix ? null,
meta ? { },
@@ -69,6 +70,7 @@ lib.makeOverridable (
|| deepClone
|| forceFetchGit
|| fetchLFS
|| (rootDir != "")
|| (sparseCheckout != [ ]);
# We prefer fetchzip in cases we don't need submodules as the hash
# is more stable in that case.