-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Improve Flakeref for Gitlab repos. #8773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| #include <optional> | ||
| #include <nlohmann/json.hpp> | ||
| #include <fstream> | ||
| #include <regex> | ||
|
|
||
| namespace nix::fetchers { | ||
|
|
||
|
|
@@ -332,9 +333,10 @@ struct GitLabInputScheme : GitArchiveInputScheme | |
| Hash getRevFromRef(nix::ref<Store> store, const Input & input) const override | ||
| { | ||
| auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com"); | ||
| auto repo = std::regex_replace(getStrAttr(input.attrs, "repo"), std::regex("/"), "%2F"); | ||
| // See rate limiting note below | ||
| auto url = fmt("https://%s/api/v4/projects/%s%%2F%s/repository/commits?ref_name=%s", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we constructing urls with string concatenation 🤦
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value of repo has to go into the url encoded, one way or another. The goal of this change is to allow both |
||
| host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo"), *input.getRef()); | ||
| host, getStrAttr(input.attrs, "owner"), repo, *input.getRef()); | ||
|
|
||
| Headers headers = makeHeadersWithAuthTokens(host); | ||
|
|
||
|
|
@@ -355,8 +357,9 @@ struct GitLabInputScheme : GitArchiveInputScheme | |
| // is 10 reqs/sec/ip-addr. See | ||
| // https://docs.gitlab.com/ee/user/gitlab_com/index.html#gitlabcom-specific-rate-limits | ||
| auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com"); | ||
| auto repo = std::regex_replace(getStrAttr(input.attrs, "repo"), std::regex("/"), "%2F"); | ||
| auto url = fmt("https://%s/api/v4/projects/%s%%2F%s/repository/archive.tar.gz?sha=%s", | ||
| host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo"), | ||
| host, getStrAttr(input.attrs, "owner"), repo, | ||
| input.getRev()->to_string(Base16, false)); | ||
|
|
||
| Headers headers = makeHeadersWithAuthTokens(host); | ||
|
|
@@ -366,9 +369,10 @@ struct GitLabInputScheme : GitArchiveInputScheme | |
| void clone(const Input & input, const Path & destDir) const override | ||
| { | ||
| auto host = maybeGetStrAttr(input.attrs, "host").value_or("gitlab.com"); | ||
| auto repo = std::regex_replace(getStrAttr(input.attrs, "repo"), std::regex("/"), "%2F"); | ||
| // FIXME: get username somewhere | ||
| Input::fromURL(fmt("git+https://%s/%s/%s.git", | ||
| host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo"))) | ||
| host, getStrAttr(input.attrs, "owner"), repo)) | ||
| .applyOverrides(input.getRef(), input.getRev()) | ||
| .clone(destDir); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.