Add detection for GitHub AE.
This commit is contained in:
parent
781e3bc540
commit
0656b2c1ad
10 changed files with 27 additions and 6 deletions
2
lib/upload-lib.js
generated
2
lib/upload-lib.js
generated
|
|
@ -162,7 +162,7 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
|
|||
base_sha: undefined,
|
||||
};
|
||||
// This behaviour can be made the default when support for GHES 3.0 is discontinued.
|
||||
if (gitHubVersion.type === "dotcom" ||
|
||||
if (gitHubVersion.type !== "ghes" ||
|
||||
semver.satisfies(gitHubVersion.version, `>=3.1`)) {
|
||||
if (process.env.GITHUB_EVENT_NAME === "pull_request" &&
|
||||
process.env.GITHUB_EVENT_PATH) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
3
lib/util.js
generated
3
lib/util.js
generated
|
|
@ -211,6 +211,9 @@ async function getGitHubVersion(apiDetails) {
|
|||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === undefined) {
|
||||
return { type: "dotcom" };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "GitHub AE") {
|
||||
return { type: "ghae" };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: "ghes", version };
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
6
lib/util.test.js
generated
6
lib/util.test.js
generated
|
|
@ -159,6 +159,12 @@ ava_1.default("getGitHubVersion", async (t) => {
|
|||
url: "https://ghe.example.com",
|
||||
});
|
||||
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: "",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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: "",
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue