Skip to content

Commit

Permalink
gitTags: ignore repos with no tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Oct 23, 2020
1 parent a86aef6 commit 1524688
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/package-managers/gitTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const greatest = async (name, version, options) => {
}
// catch a variety of errors that occur on invalid or private repos
catch (e) {
print(options, `Invalid or Private repo ${name}: ${version}`, 'verbose')
print(options, `Invalid, private repo, or no tags for ${name}: ${version}`, 'verbose')
return null
}

Expand All @@ -28,7 +28,9 @@ const greatest = async (name, version, options) => {
.filter(semver.valid)
.sort(versionUtil.compareVersions)
const latestVersion = tags[tags.length - 1]
return versionUtil.upgradeGithubUrl(version, latestVersion)
return latestVersion
? versionUtil.upgradeGithubUrl(version, latestVersion)
: null
}

module.exports = {
Expand Down
10 changes: 9 additions & 1 deletion test/test-versionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,15 @@ describe('versionmanager', () => {
})
})

it('private github urls with tags should be ignored', async () => {
it('ignore repos with no tags', async () => {
const upgrades = await vm.queryVersions({
// this repo has tag "1.0" which is not valid semver
'ncu-test-invalid-tag': 'git+https://github.com/raineorshine/ncu-test-no-tags#v1'
}, { loglevel: 'silent' })
upgrades.should.deep.equal({})
})

it('valid but non-existent github urls with tags should be ignored', async () => {
const upgrades = await vm.queryVersions({
'ncu-test-alpha': 'git+https://username:dh9dnas0nndnjnjasd4@bitbucket.org/somename/common.git#v283',
'ncu-test-private': 'https://github.com/ncu-test/ncu-test-private#v999.9.9',
Expand Down

0 comments on commit 1524688

Please sign in to comment.