1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

logs around getFingerprint

This commit is contained in:
Brian Camacho 2024-11-12 02:17:06 -05:00
parent b69fb151c4
commit 9a6388dce6
3 changed files with 18 additions and 5 deletions

View file

@ -380,7 +380,9 @@ void Fetch::init(git_repository* repo, std::string gitattributesContent) {
const auto remoteUrl = lfs::getLfsEndpointUrl(repo);
this->gitUrl = parseGitUrl(remoteUrl);
this->token = lfs::getLfsApiToken(this->gitUrl);
if (this->gitUrl.protocol == "ssh") {
this->token = lfs::getLfsApiToken(this->gitUrl);
}
this->rules = lfs::parseGitAttrFile(gitattributesContent);
this->ready = true;
}
@ -420,14 +422,17 @@ std::vector<nlohmann::json> Fetch::fetchUrls(const std::vector<Md> &metadatas) c
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curlErrBuf);
std::string responseString;
std::string headerString;
auto lfsUrlBatch = gitUrl.toHttp() + "/info/lfs/objects/batch";
const auto lfsUrlBatch = gitUrl.toHttp() + "/info/lfs/objects/batch";
curl_easy_setopt(curl, CURLOPT_URL, lfsUrlBatch.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataStr.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
struct curl_slist *headers = NULL;
auto authHeader = "Authorization: " + token;
headers = curl_slist_append(headers, authHeader.c_str());
if (this->token != "") {
const auto authHeader = "Authorization: " + token;
headers = curl_slist_append(headers, authHeader.c_str());
}
headers =
curl_slist_append(headers, "Content-Type: application/vnd.git-lfs+json");
headers = curl_slist_append(headers, "Accept: application/vnd.git-lfs+json");

View file

@ -642,6 +642,7 @@ struct GitInputScheme : InputScheme
bool exportIgnore = getExportIgnoreAttr(input);
bool smudgeLfs = getLfsAttr(input);
std::cerr << "smudgeLfs: " << smudgeLfs << std::endl;
auto accessor = repo->getAccessor(rev, exportIgnore, smudgeLfs);
accessor->setPathDisplay("«" + input.to_string() + "»");
@ -803,7 +804,11 @@ struct GitInputScheme : InputScheme
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
{
if (auto rev = input.getRev())
return rev->gitRev() + (getSubmodulesAttr(input) ? ";s" : "") + (getExportIgnoreAttr(input) ? ";e" : "") + (getLfsAttr(input) ? ";l" : "");
{
const auto s = rev->gitRev() + (getSubmodulesAttr(input) ? ";s" : "") + (getExportIgnoreAttr(input) ? ";e" : "") + (getLfsAttr(input) ? ";l" : "");
std::cerr << "getFingerprint: " << s << std::endl;
return s;
}
else
return std::nullopt;
}

View file

@ -53,11 +53,14 @@
}}
"""
# fetch the repo via nix
fetched_lfs = client.succeed(f"""
nix eval --impure --raw --expr '({fetchGit_lfs_expr}).outPath'
""")
assert fetched_lfs != fetched_nolfs, f"fetching with and without lfs yielded the same store path {fetched_lfs}, fingerprinting error?"
# check that file was smudged
file_size_lfs = client.succeed(f"""
stat -c %s {fetched_lfs}/beeg