mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
Merge branch 'slashes-in-github-branches' of https://github.com/Ma27/nix
This commit is contained in:
commit
1bbc66f865
2 changed files with 18 additions and 4 deletions
|
@ -37,15 +37,29 @@ struct GitArchiveInputScheme : InputScheme
|
||||||
std::optional<std::string> ref;
|
std::optional<std::string> ref;
|
||||||
std::optional<std::string> host_url;
|
std::optional<std::string> host_url;
|
||||||
|
|
||||||
if (path.size() == 2) {
|
auto size = path.size();
|
||||||
} else if (path.size() == 3) {
|
if (size == 3) {
|
||||||
if (std::regex_match(path[2], revRegex))
|
if (std::regex_match(path[2], revRegex))
|
||||||
rev = Hash::parseAny(path[2], htSHA1);
|
rev = Hash::parseAny(path[2], htSHA1);
|
||||||
else if (std::regex_match(path[2], refRegex))
|
else if (std::regex_match(path[2], refRegex))
|
||||||
ref = path[2];
|
ref = path[2];
|
||||||
else
|
else
|
||||||
throw BadURL("in URL '%s', '%s' is not a commit hash or branch/tag name", url.url, path[2]);
|
throw BadURL("in URL '%s', '%s' is not a commit hash or branch/tag name", url.url, path[2]);
|
||||||
} else
|
} else if (size > 3) {
|
||||||
|
std::string rs;
|
||||||
|
for (auto i = std::next(path.begin(), 2); i != path.end(); i++) {
|
||||||
|
rs += *i;
|
||||||
|
if (std::next(i) != path.end()) {
|
||||||
|
rs += "/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::regex_match(rs, refRegex)) {
|
||||||
|
ref = rs;
|
||||||
|
} else {
|
||||||
|
throw BadURL("in URL '%s', '%s' is not a branch/tag name", url.url, rs);
|
||||||
|
}
|
||||||
|
} else if (size < 2)
|
||||||
throw BadURL("URL '%s' is invalid", url.url);
|
throw BadURL("URL '%s' is invalid", url.url);
|
||||||
|
|
||||||
for (auto &[name, value] : url.query) {
|
for (auto &[name, value] : url.query) {
|
||||||
|
|
|
@ -23,7 +23,7 @@ const static std::string absPathRegex = "(?:(?:/" + segmentRegex + ")*/?)";
|
||||||
const static std::string pathRegex = "(?:" + segmentRegex + "(?:/" + segmentRegex + ")*/?)";
|
const static std::string pathRegex = "(?:" + segmentRegex + "(?:/" + segmentRegex + ")*/?)";
|
||||||
|
|
||||||
// A Git ref (i.e. branch or tag name).
|
// A Git ref (i.e. branch or tag name).
|
||||||
const static std::string refRegexS = "[a-zA-Z0-9][a-zA-Z0-9_.-]*"; // FIXME: check
|
const static std::string refRegexS = "[a-zA-Z0-9][a-zA-Z0-9_.\\/-]*"; // FIXME: check
|
||||||
extern std::regex refRegex;
|
extern std::regex refRegex;
|
||||||
|
|
||||||
// Instead of defining what a good Git Ref is, we define what a bad Git Ref is
|
// Instead of defining what a good Git Ref is, we define what a bad Git Ref is
|
||||||
|
|
Loading…
Reference in a new issue