Skip to content

Commit

Permalink
Fix github dependency upgrades with partial semver (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
markablov authored Jul 7, 2021
1 parent 9066f31 commit 6961198
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/versionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
6 changes: 6 additions & 0 deletions test/versionmanager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6961198

Please sign in to comment.