Skip to content

Commit 7b49ba6

Browse files
authored
Merge pull request #214 from Sharpie/update-update-components
Update update components
2 parents be854a9 + ee313d1 commit 7b49ba6

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

tasks/update_components.rake

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ def github_owner_repo(url)
2424
[Regexp.last_match(1), Regexp.last_match(2).sub(/\.git$/, '')]
2525
end
2626

27-
# Normalize a version string by stripping common tag prefixes.
27+
# Normalize a version string by stripping common tag prefixes and
28+
# replacing underscores with .
2829
def normalize_version(tag)
30+
return nil if tag.nil?
31+
2932
tag.sub(/\Av(?=\d)/, '')
3033
.sub(/\Arefs\/tags\/v?/, '')
3134
.sub(/\Arelease-/, '')
3235
.sub(/\Aopenssl-/, '')
36+
.sub(/\Acurl-/, '')
37+
.gsub('_', '.')
3338
end
3439

3540
# Try to parse a version from a normalized string, returning nil if unparseable.
@@ -50,11 +55,12 @@ end
5055
# and somme people, like openssl, maintain multiple streams. So the latest tag might not be the highest version
5156
# We do some version comparison to find the actual highest version
5257
def latest_github_tag(owner, repo)
53-
github_client.tags("#{owner}/#{repo}", per_page: 100)
54-
.map { |tag| [tag.name, try_version(normalize_version(tag.name))] }
55-
.reject { |_, version| version.nil? || version.prerelease? }
56-
.max_by { |_, version| version }
57-
.first
58+
tags = github_client.tags("#{owner}/#{repo}", per_page: 100)
59+
.map { |tag| [tag.name, try_version(normalize_version(tag.name))] }
60+
.reject { |_, version| version.nil? || version.prerelease? }
61+
.max_by { |_, version| version }
62+
63+
tags.nil? ? tags : tags.first
5864
end
5965

6066
def current_version(data)

0 commit comments

Comments
 (0)