From f07a7a33c01ba04b5cf8f90c7c8d95a0996713b0 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Thu, 8 Feb 2018 13:22:39 +0100 Subject: [PATCH] fix: strip trailing #something from manual repository url --- lib/workers/pr/changelog.js | 6 +- .../pr/__snapshots__/changelog.spec.js.snap | 61 ------------------- test/workers/pr/changelog.spec.js | 8 --- 3 files changed, 5 insertions(+), 70 deletions(-) diff --git a/lib/workers/pr/changelog.js b/lib/workers/pr/changelog.js index f49b0ff1ca..e2a86b6e62 100644 --- a/lib/workers/pr/changelog.js +++ b/lib/workers/pr/changelog.js @@ -52,11 +52,15 @@ async function getChangeLogJSON(depName, fromVersion, newVersion) { if (!res) { logger.debug('Checking for github source URL manually'); const dep = await npmRegistry.getDependency(depName); + // istanbul ignore if if (dep && dep.repositoryUrl) { logger.info('Found github URL manually'); + const github = dep.repositoryUrl + .replace('https://github.com/', '') + .replace(/#.*/, ''); res = { project: { - github: dep.repositoryUrl.replace('https://github.com/', ''), + github, }, versions: Object.keys(dep.versions) .filter(v => semver.satisfies(v, semverString)) diff --git a/test/workers/pr/__snapshots__/changelog.spec.js.snap b/test/workers/pr/__snapshots__/changelog.spec.js.snap index a5cbc1862a..268593f10c 100644 --- a/test/workers/pr/__snapshots__/changelog.spec.js.snap +++ b/test/workers/pr/__snapshots__/changelog.spec.js.snap @@ -1,66 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`workers/pr/changelog getChangeLogJSON finds dep manually 1`] = ` -Object { - "hasReleaseNotes": false, - "project": Object { - "github": "renovateapp/renovate", - }, - "versions": Array [ - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.1.0", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.2.0", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.3.0", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.4.0", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.4.1", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.4.2", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.4.3", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.4.4", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "2.4.5", - }, - Object { - "changes": Array [], - "releaseNotes": undefined, - "version": "3.0.0", - }, - ], -} -`; - exports[`workers/pr/changelog getChangeLogJSON sorts JSON 1`] = ` Object { "hasReleaseNotes": false, diff --git a/test/workers/pr/changelog.spec.js b/test/workers/pr/changelog.spec.js index d1da043dfc..158ce9860b 100644 --- a/test/workers/pr/changelog.spec.js +++ b/test/workers/pr/changelog.spec.js @@ -33,14 +33,6 @@ describe('workers/pr/changelog', () => { await changelogHelper.getChangeLogJSON('renovate', '1.0.0', '2.0.0') ).toMatchObject({ a: 1 }); }); - it('finds dep manually', async () => { - changelog.generate = jest.fn(() => { - throw new Error('Unknown Github Repo'); - }); - expect( - await changelogHelper.getChangeLogJSON('renovate', '2.0.0', '3.0.0') - ).toMatchSnapshot(); - }); it('filters unnecessary warns', async () => { changelog.generate = jest.fn(() => { throw new Error('Unknown Github Repo');