Module: Homebrew::Vulns::Semver Private

Defined in:
vulns/semver.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

SemVer 2.0 comparison for OSV SEMVER ranges (https://semver.org/#spec-item-11). Kept separate from ::Version, whose ordering differs for prerelease and build metadata. Minor/patch may be omitted; other spec violations return nil.

Class Method Summary collapse

Class Method Details

.compare(left, right) ⇒ Integer?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



34
35
36
37
38
39
40
41
42
43
# File 'vulns/semver.rb', line 34

def self.compare(left, right)
  a = parse(left)
  b = parse(right)
  return if a.nil? || b.nil?

  core = a.fetch(:core) <=> b.fetch(:core)
  return core unless core.zero?

  compare_prerelease(a.fetch(:prerelease), b.fetch(:prerelease))
end