-
Notifications
You must be signed in to change notification settings - Fork 329
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to also add this variant to the tests in
Lines 304 to 339 in 760583e
export enum GitHubVariant { | |
DOTCOM, | |
GHES, | |
GHAE, | |
} | |
export type GitHubVersion = | |
| { type: GitHubVariant.DOTCOM } | |
| { type: GitHubVariant.GHAE } | |
| { type: GitHubVariant.GHES; version: string }; | |
export async function getGitHubVersion( | |
apiDetails: GitHubApiDetails | |
): Promise<GitHubVersion> { | |
// We can avoid making an API request in the standard dotcom case | |
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) { | |
return { type: GitHubVariant.DOTCOM }; | |
} | |
// Doesn't strictly have to be the meta endpoint as we're only | |
// using the response headers which are available on every request. | |
const apiClient = getApiClient(); | |
const response = await apiClient.meta.get(); | |
// This happens on dotcom, although we expect to have already returned in that | |
// case. This can also serve as a fallback in cases we haven't foreseen. | |
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === undefined) { | |
return { type: GitHubVariant.DOTCOM }; | |
} | |
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "GitHub AE") { | |
return { type: GitHubVariant.GHAE }; | |
} | |
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] as string; | |
return { type: GitHubVariant.GHES, version }; | |
} |
a9af051
to
3ca2260
Compare
Thanks, test added! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized I linked the non-test file 😆 but you understood what I meant!
Merge / deployment checklist