Merge pull request #10811 from Mic92/fetcher-fix

libfetchers: handle nonexistent refs in GitLab repos more gracefully
This commit is contained in:
Robert Hensing 2024-05-31 12:24:28 +02:00 committed by GitHub
commit 962475d97f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -433,9 +433,15 @@ struct GitLabInputScheme : GitArchiveInputScheme
store->toRealPath( store->toRealPath(
downloadFile(store, url, "source", headers).storePath))); downloadFile(store, url, "source", headers).storePath)));
return RefInfo { if (json.is_array() && json.size() == 1 && json[0]["id"] != nullptr) {
.rev = Hash::parseAny(std::string(json[0]["id"]), HashAlgorithm::SHA1) return RefInfo {
}; .rev = Hash::parseAny(std::string(json[0]["id"]), HashAlgorithm::SHA1)
};
} if (json.is_array() && json.size() == 0) {
throw Error("No commits returned by GitLab API -- does the git ref really exist?");
} else {
throw Error("Unexpected response received from GitLab: %s", json);
}
} }
DownloadUrl getDownloadUrl(const Input & input) const override DownloadUrl getDownloadUrl(const Input & input) const override