1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-10-18 00:16:11 -04:00

naive lfs support

This commit is contained in:
Brian Camacho 2024-03-04 14:21:02 -08:00 committed by Brian Camacho
parent 587c7dcb2b
commit 8fb36a98ff
3 changed files with 23 additions and 0 deletions

View file

@ -318,6 +318,8 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
std::vector<std::tuple<Submodule, Hash>> 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<std::tuple<GitRepoImpl::Submodule, Hash>> GitRepoImpl::getSubmodules
return result;
}
void GitRepoImpl::smudgeLfs() {
runProgram(RunOptions{
.program = "git",
.searchPath = true,
.args = { "lfs", "pull" },
.chdir = std::make_optional(this->path)
});
}
ref<GitRepo> getTarballCache()
{
static auto repoDir = std::filesystem::path(getCacheDir()) / "nix" / "tarball-cache";

View file

@ -69,6 +69,8 @@ struct GitRepo
*/
virtual std::vector<std::tuple<Submodule, Hash>> getSubmodules(const Hash & rev, bool exportIgnore) = 0;
virtual void smudgeLfs() = 0;
virtual std::string resolveSubmoduleUrl(
const std::string & url,
const std::string & base) = 0;

View file

@ -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"));