diff --git a/src/libfetchers/git-utils.cc b/src/libfetchers/git-utils.cc index 9cae9034e..ee411cb61 100644 --- a/src/libfetchers/git-utils.cc +++ b/src/libfetchers/git-utils.cc @@ -318,6 +318,8 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this std::vector> getSubmodules(const Hash & rev, bool exportIgnore) override; + void smudgeLfs() override; + std::string resolveSubmoduleUrl( const std::string & url, const std::string & base) override @@ -1007,6 +1009,15 @@ std::vector> GitRepoImpl::getSubmodules return result; } +void GitRepoImpl::smudgeLfs() { + runProgram(RunOptions{ + .program = "git", + .searchPath = true, + .args = { "lfs", "pull" }, + .chdir = std::make_optional(this->path) + }); +} + ref getTarballCache() { static auto repoDir = std::filesystem::path(getCacheDir()) / "nix" / "tarball-cache"; diff --git a/src/libfetchers/git-utils.hh b/src/libfetchers/git-utils.hh index fbb2d947b..c45de06dc 100644 --- a/src/libfetchers/git-utils.hh +++ b/src/libfetchers/git-utils.hh @@ -69,6 +69,8 @@ struct GitRepo */ virtual std::vector> getSubmodules(const Hash & rev, bool exportIgnore) = 0; + virtual void smudgeLfs() = 0; + virtual std::string resolveSubmoduleUrl( const std::string & url, const std::string & base) = 0; diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 87d114276..0d794ddd0 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -381,6 +381,11 @@ struct GitInputScheme : InputScheme return maybeGetBoolAttr(input.attrs, "submodules").value_or(false); } + bool getLfsAttr(const Input & input) const + { + return maybeGetBoolAttr(input.attrs, "lfs").value_or(false); + } + bool getExportIgnoreAttr(const Input & input) const { return maybeGetBoolAttr(input.attrs, "exportIgnore").value_or(false); @@ -648,6 +653,11 @@ struct GitInputScheme : InputScheme } } + if (getLfsAttr(input)) { + // urlencoded `?lfs=1` param is set, + repo->smudgeLfs(); + } + assert(!origRev || origRev == rev); if (!getShallowAttr(input)) input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount"));