mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 21:21:00 +01:00
Merge pull request #14582 from NixOS/ref-to-reference
libfetchers: Convert ref<Store> -> Store &
This commit is contained in:
commit
77982c55b2
27 changed files with 119 additions and 119 deletions
|
|
@ -258,7 +258,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||
std::optional<Hash> treeHash;
|
||||
};
|
||||
|
||||
virtual RefInfo getRevFromRef(const Settings & settings, nix::ref<Store> store, const Input & input) const = 0;
|
||||
virtual RefInfo getRevFromRef(const Settings & settings, nix::Store & store, const Input & input) const = 0;
|
||||
|
||||
virtual DownloadUrl getDownloadUrl(const Settings & settings, const Input & input) const = 0;
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||
time_t lastModified;
|
||||
};
|
||||
|
||||
std::pair<Input, TarballInfo> downloadArchive(const Settings & settings, ref<Store> store, Input input) const
|
||||
std::pair<Input, TarballInfo> downloadArchive(const Settings & settings, Store & store, Input input) const
|
||||
{
|
||||
if (!maybeGetStrAttr(input.attrs, "ref"))
|
||||
input.attrs.insert_or_assign("ref", "HEAD");
|
||||
|
|
@ -341,7 +341,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||
}
|
||||
|
||||
std::pair<ref<SourceAccessor>, Input>
|
||||
getAccessor(const Settings & settings, ref<Store> store, const Input & _input) const override
|
||||
getAccessor(const Settings & settings, Store & store, const Input & _input) const override
|
||||
{
|
||||
auto [input, tarballInfo] = downloadArchive(settings, store, _input);
|
||||
|
||||
|
|
@ -370,7 +370,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||
return Xp::Flakes;
|
||||
}
|
||||
|
||||
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
|
||||
std::optional<std::string> getFingerprint(Store & store, const Input & input) const override
|
||||
{
|
||||
if (auto rev = input.getRev())
|
||||
return rev->gitRev();
|
||||
|
|
@ -418,7 +418,7 @@ struct GitHubInputScheme : GitArchiveInputScheme
|
|||
return getStrAttr(input.attrs, "repo");
|
||||
}
|
||||
|
||||
RefInfo getRevFromRef(const Settings & settings, nix::ref<Store> store, const Input & input) const override
|
||||
RefInfo getRevFromRef(const Settings & settings, nix::Store & store, const Input & input) const override
|
||||
{
|
||||
auto host = getHost(input);
|
||||
auto url = fmt(
|
||||
|
|
@ -432,7 +432,7 @@ struct GitHubInputScheme : GitArchiveInputScheme
|
|||
|
||||
auto downloadResult = downloadFile(store, settings, url, "source", headers);
|
||||
auto json = nlohmann::json::parse(
|
||||
store->requireStoreObjectAccessor(downloadResult.storePath)->readFile(CanonPath::root));
|
||||
store.requireStoreObjectAccessor(downloadResult.storePath)->readFile(CanonPath::root));
|
||||
|
||||
return RefInfo{
|
||||
.rev = Hash::parseAny(std::string{json["sha"]}, HashAlgorithm::SHA1),
|
||||
|
|
@ -457,7 +457,7 @@ struct GitHubInputScheme : GitArchiveInputScheme
|
|||
return DownloadUrl{parseURL(url), headers};
|
||||
}
|
||||
|
||||
void clone(const Settings & settings, ref<Store> store, const Input & input, const std::filesystem::path & destDir)
|
||||
void clone(const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir)
|
||||
const override
|
||||
{
|
||||
auto host = getHost(input);
|
||||
|
|
@ -499,7 +499,7 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
|||
return std::make_pair(token.substr(0, fldsplit), token.substr(fldsplit + 1));
|
||||
}
|
||||
|
||||
RefInfo getRevFromRef(const Settings & settings, nix::ref<Store> store, const Input & input) const override
|
||||
RefInfo getRevFromRef(const Settings & settings, nix::Store & store, const Input & input) const override
|
||||
{
|
||||
auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com");
|
||||
// See rate limiting note below
|
||||
|
|
@ -514,7 +514,7 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
|||
|
||||
auto downloadResult = downloadFile(store, settings, url, "source", headers);
|
||||
auto json = nlohmann::json::parse(
|
||||
store->requireStoreObjectAccessor(downloadResult.storePath)->readFile(CanonPath::root));
|
||||
store.requireStoreObjectAccessor(downloadResult.storePath)->readFile(CanonPath::root));
|
||||
|
||||
if (json.is_array() && json.size() >= 1 && json[0]["id"] != nullptr) {
|
||||
return RefInfo{.rev = Hash::parseAny(std::string(json[0]["id"]), HashAlgorithm::SHA1)};
|
||||
|
|
@ -545,7 +545,7 @@ struct GitLabInputScheme : GitArchiveInputScheme
|
|||
return DownloadUrl{parseURL(url), headers};
|
||||
}
|
||||
|
||||
void clone(const Settings & settings, ref<Store> store, const Input & input, const std::filesystem::path & destDir)
|
||||
void clone(const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir)
|
||||
const override
|
||||
{
|
||||
auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com");
|
||||
|
|
@ -581,7 +581,7 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||
// Once it is implemented, however, should work as expected.
|
||||
}
|
||||
|
||||
RefInfo getRevFromRef(const Settings & settings, nix::ref<Store> store, const Input & input) const override
|
||||
RefInfo getRevFromRef(const Settings & settings, nix::Store & store, const Input & input) const override
|
||||
{
|
||||
// TODO: In the future, when the sourcehut graphql API is implemented for mercurial
|
||||
// and with anonymous access, this method should use it instead.
|
||||
|
|
@ -597,7 +597,7 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||
std::string refUri;
|
||||
if (ref == "HEAD") {
|
||||
auto downloadFileResult = downloadFile(store, settings, fmt("%s/HEAD", base_url), "source", headers);
|
||||
auto contents = store->requireStoreObjectAccessor(downloadFileResult.storePath)->readFile(CanonPath::root);
|
||||
auto contents = store.requireStoreObjectAccessor(downloadFileResult.storePath)->readFile(CanonPath::root);
|
||||
|
||||
auto remoteLine = git::parseLsRemoteLine(getLine(contents).first);
|
||||
if (!remoteLine) {
|
||||
|
|
@ -610,7 +610,7 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||
std::regex refRegex(refUri);
|
||||
|
||||
auto downloadFileResult = downloadFile(store, settings, fmt("%s/info/refs", base_url), "source", headers);
|
||||
auto contents = store->requireStoreObjectAccessor(downloadFileResult.storePath)->readFile(CanonPath::root);
|
||||
auto contents = store.requireStoreObjectAccessor(downloadFileResult.storePath)->readFile(CanonPath::root);
|
||||
std::istringstream is(contents);
|
||||
|
||||
std::string line;
|
||||
|
|
@ -641,7 +641,7 @@ struct SourceHutInputScheme : GitArchiveInputScheme
|
|||
return DownloadUrl{parseURL(url), headers};
|
||||
}
|
||||
|
||||
void clone(const Settings & settings, ref<Store> store, const Input & input, const std::filesystem::path & destDir)
|
||||
void clone(const Settings & settings, Store & store, const Input & input, const std::filesystem::path & destDir)
|
||||
const override
|
||||
{
|
||||
auto host = maybeGetStrAttr(input.attrs, "host").value_or("git.sr.ht");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue