aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-05-10 19:23:22 +0200
committerGitHub <noreply@github.com>2022-05-10 19:23:22 +0200
commiteb957ad6d8f7375e9b78f4b3696912dded95f7a6 (patch)
treef9c194480bd5eb7cd2038761f73048993aaaab68
parent73b9b008f07ea960b4c9af81a25223aee4a041b7 (diff)
parent7a3d5b2ff0e39ae0d7b393f454671a08da56776b (diff)
Merge pull request #6497 from danielfullmer/ghe-fetcher-url
Use correct URL for GitHub Enterprise
-rw-r--r--src/libfetchers/github.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc
index a1084c984..0721a13f2 100644
--- a/src/libfetchers/github.cc
+++ b/src/libfetchers/github.cc
@@ -243,7 +243,10 @@ struct GitHubInputScheme : GitArchiveInputScheme
Hash getRevFromRef(nix::ref<Store> store, const Input & input) const override
{
auto host = maybeGetStrAttr(input.attrs, "host").value_or("github.com");
- auto url = fmt("https://api.%s/repos/%s/%s/commits/%s", // FIXME: check
+ auto url = fmt(
+ host == "github.com"
+ ? "https://api.%s/repos/%s/%s/commits/%s"
+ : "https://%s/api/v3/repos/%s/%s/commits/%s",
host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo"), *input.getRef());
Headers headers = makeHeadersWithAuthTokens(host);
@@ -262,7 +265,10 @@ struct GitHubInputScheme : GitArchiveInputScheme
// FIXME: use regular /archive URLs instead? api.github.com
// might have stricter rate limits.
auto host = maybeGetStrAttr(input.attrs, "host").value_or("github.com");
- auto url = fmt("https://api.%s/repos/%s/%s/tarball/%s", // FIXME: check if this is correct for self hosted instances
+ auto url = fmt(
+ host == "github.com"
+ ? "https://api.%s/repos/%s/%s/commits/%s"
+ : "https://%s/api/v3/repos/%s/%s/commits/%s",
host, getStrAttr(input.attrs, "owner"), getStrAttr(input.attrs, "repo"),
input.getRev()->to_string(Base16, false));