File tree 2 files changed +2
-24
lines changed
2 files changed +2
-24
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package buildinfo
3
3
import (
4
4
"fmt"
5
5
"runtime/debug"
6
- "strings"
7
6
"sync"
8
7
"time"
9
8
@@ -61,25 +60,11 @@ func Version() string {
61
60
func VersionsMatch (v1 , v2 string ) bool {
62
61
// Developer versions are disregarded...hopefully they know what they are
63
62
// doing.
64
- if strings . HasPrefix (v1 , develPrefix ) || strings . HasPrefix (v2 , develPrefix ) {
63
+ if semver . Prerelease (v1 ) != "" || semver . Prerelease (v2 ) != "" {
65
64
return true
66
65
}
67
66
68
- v1Toks := strings .Split (v1 , "." )
69
- v2Toks := strings .Split (v2 , "." )
70
-
71
- // Versions should be formatted as "<major>.<minor>.<patch>".
72
- // We assume malformed versions are evidence of a bug and return false.
73
- if len (v1Toks ) < 3 || len (v2Toks ) < 3 {
74
- return false
75
- }
76
-
77
- // Slice off the patch suffix. Patch versions should be non-breaking
78
- // changes.
79
- v1MajorMinor := strings .Join (v1Toks [:2 ], "." )
80
- v2MajorMinor := strings .Join (v2Toks [:2 ], "." )
81
-
82
- return v1MajorMinor == v2MajorMinor
67
+ return semver .Compare (semver .MajorMinor (v1 ), semver .MajorMinor (v2 )) == 0
83
68
}
84
69
85
70
// ExternalURL returns a URL referencing the current Coder version.
Original file line number Diff line number Diff line change @@ -48,13 +48,6 @@ func TestBuildInfo(t *testing.T) {
48
48
v2 : "v1.2.3" ,
49
49
expectMatch : true ,
50
50
},
51
- // Test that we return false if a version is malformed.
52
- {
53
- name : "MalformedIgnored" ,
54
- v1 : "v1.2.3" ,
55
- v2 : "v1.2" ,
56
- expectMatch : false ,
57
- },
58
51
// Test that we return true if a developer version is detected.
59
52
// Developers do not need to be warned of mismatched versions.
60
53
{
You can’t perform that action at this time.
0 commit comments