forked from actions/checkout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <mail@markus-wolf.de>
- Loading branch information
1 parent
83b7061
commit 590916f
Showing
4 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as github from '@actions/github' | ||
import * as githubApiHelper from '../lib/github-api-helper' | ||
|
||
jest.mock('@actions/github') | ||
|
||
describe('github-api-helper tests', () => { | ||
describe('github enterprise compatibility', () => { | ||
beforeEach(() => { | ||
process.env.GITHUB_SERVER_URL = 'https://enterprise.git.com' | ||
}) | ||
|
||
afterEach(() => { | ||
delete process.env.GITHUB_SERVER_URL | ||
}) | ||
|
||
it('getDefaultBranch should use GITHUB_SERVER_URL to set the baseUrl', async () => { | ||
;(github.getOctokit as jest.Mock).mockImplementation(() => { | ||
return { | ||
rest: { | ||
repos: { | ||
get: jest.fn(() => ({data: {default_branch: 'default-branch'}})) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
await githubApiHelper.getDefaultBranch('token', 'owner', 'repo') | ||
|
||
expect(github.getOctokit).toHaveBeenCalledWith( | ||
'token', | ||
expect.objectContaining({ | ||
baseUrl: 'https://enterprise.git.com/api/v3' | ||
}) | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters