From e66ededcfd72b51e844647f72f22f0d45f679db2 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 13 Sep 2018 05:44:27 +0200 Subject: [PATCH] =?UTF-8?q?fix(ghe):=20don=E2=80=99t=20escape=20PR=20bodie?= =?UTF-8?q?s=20if=20using=20non-github.com=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/platform/github/index.js | 4 ++-- test/platform/github/index.spec.js | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index f942460244..5d8b2c2705 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 16532932e6..ffa000898e 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', () => { -- GitLab