Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for versioning of ghe.com #1597

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/feature-flags.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions lib/util.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.test.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export type CodeQLDefaultVersionInfo =
| {
cliVersion: string;
tagName: string;
variant: util.GitHubVariant.GHAE | util.GitHubVariant.GHES;
variant:
| util.GitHubVariant.GHAE
| util.GitHubVariant.GHES
| util.GitHubVariant.GHE_DOTCOM;
};

export interface FeatureEnablement {
Expand Down
8 changes: 8 additions & 0 deletions src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ test("getGitHubVersion", async (t) => {
apiURL: undefined,
});
t.deepEqual({ type: util.GitHubVariant.DOTCOM }, v3);

mockGetMetaVersionHeader("ghe.com");
const gheDotcom = await util.getGitHubVersion({
auth: "",
url: "https://foo.ghe.com",
apiURL: undefined,
});
t.deepEqual({ type: util.GitHubVariant.GHE_DOTCOM }, gheDotcom);
});

const ML_POWERED_JS_STATUS_TESTS: Array<[string[], string]> = [
Expand Down
6 changes: 6 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,12 @@ export enum GitHubVariant {
DOTCOM,
GHES,
GHAE,
GHE_DOTCOM,
}
export type GitHubVersion =
| { type: GitHubVariant.DOTCOM }
| { type: GitHubVariant.GHAE }
| { type: GitHubVariant.GHE_DOTCOM }
| { type: GitHubVariant.GHES; version: string };

export async function getGitHubVersion(
Expand All @@ -334,6 +336,10 @@ export async function getGitHubVersion(
return { type: GitHubVariant.GHAE };
}

if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
return { type: GitHubVariant.GHE_DOTCOM };
}

const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] as string;
return { type: GitHubVariant.GHES, version };
}
Expand Down