Skip to content

Conversation

@ZauberNerd
Copy link

The PR #1246 replaced the getOctokit method from the octokit-provider.ts file with the getOctokit method from the @actions/github package.
The octokit-provider was previously responsible for creating an Octokit instance and setting the baseUrl via the getServerApiUrl helper function. This function calls getServerUrl which reads the server url from the GITHUB_SERVER_URL environment variable, which on GHES is set to the enterprise instance.
This commit restores the previous behaviour by calling getServerApiUrl in all places where an octokit instance is created.

The PR actions#1246 replaced the `getOctokit` method from the
`octokit-provider.ts` file with the `getOctokit` method from the
`@actions/github` package.
The octokit-provider was previously responsible for creating an Octokit
instance and setting the `baseUrl` via the `getServerApiUrl` helper
function. This function calls `getServerUrl` which reads the server url
from the `GITHUB_SERVER_URL` environment variable, which on GHES is set
to the enterprise instance.
This commit restores the previous behaviour by calling `getServerApiUrl`
in all places where an octokit instance is created.

Co-authored-by: Markus Wolf <[email protected]>
})

it('getDefaultBranch should use GITHUB_SERVER_URL to set the baseUrl', async () => {
;(github.getOctokit as jest.Mock).mockImplementation(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the ; necessary for this typecast?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically no, but the prettier configuration in this repository seems to require it. At least the format-check fails without it and format adds it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, my mistake, it is correct. The ; is to prevent the parentheses of (github.getOctokit as jest.Mock) to be interpreted as function invocation in case later statement is added above.

console.log('foo')
(github.getOctokit as jest.Mock)

would be read as console.log('foo')(github.getOctokit as jest.Mock), the ; prevents it.

@fhammerl
Copy link
Contributor

We're already rolling out the hotfix (with the exact same changes :) )

I'll merge this PR regardless, thanks for the unit test.

@ZauberNerd ZauberNerd closed this Jun 21, 2024
@ZauberNerd ZauberNerd deleted the fix-ghes-server-url branch June 21, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants