Skip to content

Commit

Permalink
Merge pull request #1597 from github/rneatherway/ghe-dotcom
Browse files Browse the repository at this point in the history
Account for versioning of ghe.com
  • Loading branch information
rneatherway authored Mar 22, 2023
2 parents 760583e + 3ca2260 commit aefd989
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 4 deletions.
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

0 comments on commit aefd989

Please sign in to comment.