Skip to content

Commit 271a30c

Browse files
author
Josh Holtz
authored
Merge pull request #416 from revolter/patch-1
Add support for the new Release Candidate versions
2 parents 907414b + 0d03ed0 commit 271a30c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/xcode/install.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ def prereleases
464464
links
465465
end
466466

467+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
467468
def compare_versions(first, second)
468469
# Sort by version number
469470
numeric_comparation = first.to_f <=> second.to_f
@@ -481,9 +482,16 @@ def compare_versions(first, second)
481482
return -1 if is_first_gm && !is_second_gm
482483
return 1 if !is_first_gm && is_second_gm
483484

485+
# Return Release Candidate versions before others
486+
is_first_rc = first.include?('RC') || first.include?('Release Candidate')
487+
is_second_rc = second.include?('RC') || second.include?('Release Candidate')
488+
return -1 if is_first_rc && !is_second_rc
489+
return 1 if !is_first_rc && is_second_rc
490+
484491
# Sort alphabetically
485492
first <=> second
486493
end
494+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
487495

488496
def hdiutil(*args)
489497
io = IO.popen(['hdiutil', *args])

0 commit comments

Comments
 (0)