blob: 0b51d299bc95cbad4e38742adae78100faaaad41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
module semver
// * Private functions.
[inline]
fn version_satisfies(ver Version, input string) bool {
range := parse_range(input) or { return false }
return range.satisfies(ver)
}
fn compare_eq(v1 Version, v2 Version) bool {
return v1.major == v2.major && v1.minor == v2.minor && v1.patch == v2.patch
&& v1.prerelease == v2.prerelease
}
fn compare_gt(v1 Version, v2 Version) bool {
if v1.major < v2.major {
return false
}
if v1.major > v2.major {
return true
}
if v1.minor < v2.minor {
return false
}
if v1.minor > v2.minor {
return true
}
return v1.patch > v2.patch
}
fn compare_lt(v1 Version, v2 Version) bool {
if v1.major > v2.major {
return false
}
if v1.major < v2.major {
return true
}
if v1.minor > v2.minor {
return false
}
if v1.minor < v2.minor {
return true
}
return v1.patch < v2.patch
}
fn compare_ge(v1 Version, v2 Version) bool {
if compare_eq(v1, v2) {
return true
}
return compare_gt(v1, v2)
}
fn compare_le(v1 Version, v2 Version) bool {
if compare_eq(v1, v2) {
return true
}
return compare_lt(v1, v2)
}
|