mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
naive lfs support
This commit is contained in:
parent
587c7dcb2b
commit
8fb36a98ff
3 changed files with 23 additions and 0 deletions
|
@ -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;
|
std::vector<std::tuple<Submodule, Hash>> getSubmodules(const Hash & rev, bool exportIgnore) override;
|
||||||
|
|
||||||
|
void smudgeLfs() override;
|
||||||
|
|
||||||
std::string resolveSubmoduleUrl(
|
std::string resolveSubmoduleUrl(
|
||||||
const std::string & url,
|
const std::string & url,
|
||||||
const std::string & base) override
|
const std::string & base) override
|
||||||
|
@ -1007,6 +1009,15 @@ std::vector<std::tuple<GitRepoImpl::Submodule, Hash>> GitRepoImpl::getSubmodules
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GitRepoImpl::smudgeLfs() {
|
||||||
|
runProgram(RunOptions{
|
||||||
|
.program = "git",
|
||||||
|
.searchPath = true,
|
||||||
|
.args = { "lfs", "pull" },
|
||||||
|
.chdir = std::make_optional(this->path)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ref<GitRepo> getTarballCache()
|
ref<GitRepo> getTarballCache()
|
||||||
{
|
{
|
||||||
static auto repoDir = std::filesystem::path(getCacheDir()) / "nix" / "tarball-cache";
|
static auto repoDir = std::filesystem::path(getCacheDir()) / "nix" / "tarball-cache";
|
||||||
|
|
|
@ -69,6 +69,8 @@ struct GitRepo
|
||||||
*/
|
*/
|
||||||
virtual std::vector<std::tuple<Submodule, Hash>> getSubmodules(const Hash & rev, bool exportIgnore) = 0;
|
virtual std::vector<std::tuple<Submodule, Hash>> getSubmodules(const Hash & rev, bool exportIgnore) = 0;
|
||||||
|
|
||||||
|
virtual void smudgeLfs() = 0;
|
||||||
|
|
||||||
virtual std::string resolveSubmoduleUrl(
|
virtual std::string resolveSubmoduleUrl(
|
||||||
const std::string & url,
|
const std::string & url,
|
||||||
const std::string & base) = 0;
|
const std::string & base) = 0;
|
||||||
|
|
|
@ -381,6 +381,11 @@ struct GitInputScheme : InputScheme
|
||||||
return maybeGetBoolAttr(input.attrs, "submodules").value_or(false);
|
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
|
bool getExportIgnoreAttr(const Input & input) const
|
||||||
{
|
{
|
||||||
return maybeGetBoolAttr(input.attrs, "exportIgnore").value_or(false);
|
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);
|
assert(!origRev || origRev == rev);
|
||||||
if (!getShallowAttr(input))
|
if (!getShallowAttr(input))
|
||||||
input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount"));
|
input.attrs.insert_or_assign("revCount", getIntAttr(infoAttrs, "revCount"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue