diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-02-25 21:58:41 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-02-25 21:58:41 +0000 |
commit | 90d76fa399de4e207ea14ec4c0dd65434f60c152 (patch) | |
tree | 3c52e982cba5bcf7b91c99d1b63ba967b4ea8b92 /src/libfetchers/github.cc | |
parent | 4636cc9a1f6de70947abbfb17a0ad91981d1cad7 (diff) | |
parent | ca0994819d68aee26a2906c37a47ae609ac46c4c (diff) |
Merge remote-tracking branch 'obsidian/path-info' into ca-drv-exotic
Diffstat (limited to 'src/libfetchers/github.cc')
-rw-r--r-- | src/libfetchers/github.cc | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc index 92ff224f7..8352ef02d 100644 --- a/src/libfetchers/github.cc +++ b/src/libfetchers/github.cc @@ -37,15 +37,29 @@ struct GitArchiveInputScheme : InputScheme std::optional<std::string> ref; std::optional<std::string> host_url; - if (path.size() == 2) { - } else if (path.size() == 3) { + auto size = path.size(); + if (size == 3) { if (std::regex_match(path[2], revRegex)) rev = Hash::parseAny(path[2], htSHA1); else if (std::regex_match(path[2], refRegex)) ref = path[2]; else 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); for (auto &[name, value] : url.query) { @@ -195,14 +209,14 @@ struct GitArchiveInputScheme : InputScheme auto [tree, lastModified] = downloadTarball(store, url.url, "source", true, url.headers); - input.attrs.insert_or_assign("lastModified", lastModified); + input.attrs.insert_or_assign("lastModified", uint64_t(lastModified)); getCache()->add( store, immutableAttrs, { {"rev", rev->gitRev()}, - {"lastModified", lastModified} + {"lastModified", uint64_t(lastModified)} }, tree.storePath, true); |