From 6961198cbdb787087566b0f3e3257b5ecaac3804 Mon Sep 17 00:00:00 2001 From: markablov Date: Wed, 7 Jul 2021 14:12:05 +0300 Subject: [PATCH] Fix github dependency upgrades with partial semver (#917) --- lib/versionmanager.js | 4 ++-- test/versionmanager.test.js | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/versionmanager.js b/lib/versionmanager.js index ceb72588..a199cd3a 100644 --- a/lib/versionmanager.js +++ b/lib/versionmanager.js @@ -53,11 +53,11 @@ function upgradeDependencies(currentDependencies, latestVersions, options = {}) const currentTag = versionUtil.getGithubUrlTag(current) const [currentSemver] = semverutils.parseRange(currentTag) - currentParsed = versionUtil.stringify(currentSemver) + currentParsed = versionUtil.stringify(currentSemver, 'patch') const latestTag = versionUtil.getGithubUrlTag(latest) const [latestSemver] = semverutils.parseRange(latestTag) - latestParsed = versionUtil.stringify(latestSemver) + latestParsed = versionUtil.stringify(latestSemver, 'patch') } return { current, currentParsed, latest, latestParsed } diff --git a/test/versionmanager.test.js b/test/versionmanager.test.js index 2d596abc..13af04c7 100644 --- a/test/versionmanager.test.js +++ b/test/versionmanager.test.js @@ -288,6 +288,12 @@ describe('versionmanager', () => { vm.upgradeDependencies({ 'ncu-test-simple-tag': 'v1' }, { 'ncu-test-simple-tag': 'v3' }).should.eql({ 'ncu-test-simple-tag': 'v3' }) }) + it('upgrade github dependencies', () => { + vm.upgradeDependencies({ foo: 'github:foo/bar#v1' }, { foo: 'github:foo/bar#v2' }).should.eql({ foo: 'github:foo/bar#v2' }) + vm.upgradeDependencies({ foo: 'github:foo/bar#v1.0' }, { foo: 'github:foo/bar#v2.0' }).should.eql({ foo: 'github:foo/bar#v2.0' }) + vm.upgradeDependencies({ foo: 'github:foo/bar#v1.0.0' }, { foo: 'github:foo/bar#v2.0.0' }).should.eql({ foo: 'github:foo/bar#v2.0.0' }) + }) + it('upgrade latest versions that already satisfy the specified version', () => { vm.upgradeDependencies({ mongodb: '^1.0.0' }, { mongodb: '1.4.30' }).should.eql({ mongodb: '^1.4.30'