Skip to content

Commit 8e90ce2

Browse files
committed
Problem: git tags that don't match semver
These would currently break our version comparison Solution: exclude such tags for the time being
1 parent 3407ee6 commit 8e90ce2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/pgpm/package/git.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ module ClassMethods
1111
attr_reader :git_config
1212

1313
module Methods
14+
SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
15+
1416
def package_versions
1517
if !git_config.download_version_tags
1618
super
1719
else
1820
@tags ||=
1921
::Git.ls_remote(git_config.url)["tags"].keys
20-
.filter { |key| !key.match?(/.+\^{}$/) }
22+
.filter { |key| !key.end_with?("^{}") }
23+
.filter { |key| key.match?(SEMVER) }
2124
versions = @tags.map { |tag| tag.gsub(/^v/, "") }.map { |v| Pgpm::Package::Version.new(v) }
2225
@tag_versions = Hash[@tags.zip(versions)]
2326
@version_tags = Hash[versions.zip(@tags)]

0 commit comments

Comments
 (0)