diff options
| author | Jack Nagel | 2013-07-24 19:44:27 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-07-24 19:48:21 -0500 |
| commit | f915beb96652af78bfad0e8cafb60108e3afc890 (patch) | |
| tree | 010e2c18910c3a1ebb73ee065add4ab6142b0bb4 /Library/Homebrew/version.rb | |
| parent | 3a909c3045f40d94b72407a01c61d5ef4cd76c2a (diff) | |
| download | homebrew-f915beb96652af78bfad0e8cafb60108e3afc890.tar.bz2 | |
Adjust logic to properly sort erlang versions
Fixes #21417.
Diffstat (limited to 'Library/Homebrew/version.rb')
| -rw-r--r-- | Library/Homebrew/version.rb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index e9af49844..64ef24d1e 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -80,12 +80,12 @@ class Version class CompositeToken < StringToken def rev - value[/([0-9]+)/, 1] + value[/([0-9]+)/, 1] || "0" end end class AlphaToken < CompositeToken - PATTERN = /a(?:lpha)?[0-9]+/i + PATTERN = /a(?:lpha)?[0-9]*/i def <=>(other) case other @@ -98,7 +98,7 @@ class Version end class BetaToken < CompositeToken - PATTERN = /b(?:eta)?[0-9]+/i + PATTERN = /b(?:eta)?[0-9]*/i def <=>(other) case other @@ -115,7 +115,7 @@ class Version end class RCToken < CompositeToken - PATTERN = /rc[0-9]+/i + PATTERN = /rc[0-9]*/i def <=>(other) case other @@ -132,7 +132,7 @@ class Version end class PatchToken < CompositeToken - PATTERN = /p[0-9]+/i + PATTERN = /p[0-9]*/i def <=>(other) case other @@ -192,9 +192,18 @@ class Version protected + def begins_with_numeric? + NumericToken === tokens.first + end + def pad_to(length) - nums, rest = tokens.partition { |t| NumericToken === t } - nums.concat([NULL_TOKEN]*(length - tokens.length)).concat(rest) + if begins_with_numeric? + nums, rest = tokens.partition { |t| NumericToken === t } + nums.fill(NULL_TOKEN, nums.length, length - tokens.length) + nums.concat(rest) + else + tokens.dup.fill(NULL_TOKEN, tokens.length, length - tokens.length) + end end def tokens |
