@@ -24,12 +24,17 @@ def github_owner_repo(url)
2424 [ Regexp . last_match ( 1 ) , Regexp . last_match ( 2 ) . sub ( /\. git$/ , '' ) ]
2525end
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 .
2829def normalize_version ( tag )
30+ return nil if tag . nil?
31+
2932 tag . sub ( /\A v(?=\d )/ , '' )
3033 . sub ( /\A refs\/ tags\/ v?/ , '' )
3134 . sub ( /\A release-/ , '' )
3235 . sub ( /\A openssl-/ , '' )
36+ . sub ( /\A curl-/ , '' )
37+ . gsub ( '_' , '.' )
3338end
3439
3540# Try to parse a version from a normalized string, returning nil if unparseable.
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
5257def 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
5864end
5965
6066def current_version ( data )
0 commit comments