diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index f9424602442768da8edbb81091b88d3e1a8cfc1f..5d8b2c2705ea039511ced8bbe1c063156f9d9541 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -110,6 +110,7 @@ async function initRepo({ logger.debug('Resetting platform config'); // config is used by the platform api itself, not necessary for the app layer to know cleanRepo(); + config.isGhe = endpoint && !endpoint.startsWith('https://api.github.com'); config.localDir = localDir; config.platform = 'github'; config.repository = repository; @@ -1249,8 +1250,7 @@ async function mergePr(prNo, branchName) { } function getPrBody(input) { - const endpoint = process.env.GITHUB_ENDPOINT; - if (endpoint && !endpoint.startsWith('https://api.github.com')) { + if (config.isGhe) { return input.substring(0, 60000); } return ( diff --git a/test/platform/github/index.spec.js b/test/platform/github/index.spec.js index 16532932e6e170ea885943b48feb6be940e1c71f..ffa000898ed95330aa42fb0af5449db2ce707c7f 100644 --- a/test/platform/github/index.spec.js +++ b/test/platform/github/index.spec.js @@ -1482,13 +1482,15 @@ describe('platform/github', () => { 'https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)'; expect(github.getPrBody(input)).toMatchSnapshot(); }); - it('returns not-updated pr body for GHE', () => { - const endpoint = process.env.GITHUB_ENDPOINT; - process.env.GITHUB_ENDPOINT = 'https://github.mycompany.com'; + it('returns not-updated pr body for GHE', async () => { + await initRepo({ + repository: 'some/repo', + token: 'some-token', + endpoint: 'https://github.company.com/api/v3/', + }); const input = 'https://github.com/foo/bar/issues/5 plus also [a link](https://github.com/foo/bar/issues/5)'; expect(github.getPrBody(input)).toEqual(input); - process.env.GITHUB_ENDPOINT = endpoint; }); }); describe('mergePr(prNo) - autodetection', () => {