Add detection for GitHub AE.

This commit is contained in:
Chris Gavin 2021-02-13 11:06:03 +00:00
parent 781e3bc540
commit 0656b2c1ad
No known key found for this signature in database
GPG key ID: 07F950B80C27E4DA
10 changed files with 27 additions and 6 deletions

View file

@ -95,7 +95,7 @@ export interface Config {
codeQLCmd: string;
/**
* Version of GHES that we have determined that we are talking to, or undefined
* if talking to github.com.
* if talking to github.com or GitHub AE.
*/
gitHubVersion: GitHubVersion;
}

View file

@ -241,7 +241,7 @@ export function buildPayload(
// This behaviour can be made the default when support for GHES 3.0 is discontinued.
if (
gitHubVersion.type === "dotcom" ||
gitHubVersion.type !== "ghes" ||
semver.satisfies(gitHubVersion.version, `>=3.1`)
) {
if (

View file

@ -230,6 +230,13 @@ test("getGitHubVersion", async (t) => {
});
t.deepEqual({ type: "ghes", version: "2.0" }, v2);
mockGetMetaVersionHeader("GitHub AE");
const ghae = await util.getGitHubVersion({
auth: "",
url: "https://example.githubenterprise.com",
});
t.deepEqual({ type: "ghae" }, ghae);
mockGetMetaVersionHeader(undefined);
const v3 = await util.getGitHubVersion({
auth: "",

View file

@ -221,6 +221,7 @@ let hasBeenWarnedAboutVersion = false;
export type GitHubVersion =
| { type: "dotcom" }
| { type: "ghae" }
| { type: "ghes"; version: string };
export async function getGitHubVersion(
@ -242,6 +243,10 @@ export async function getGitHubVersion(
return { type: "dotcom" };
}
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "GitHub AE") {
return { type: "ghae" };
}
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] as string;
return { type: "ghes", version };
}