File tree Expand file tree Collapse file tree 2 files changed +2
-24
lines changed Expand file tree Collapse file tree 2 files changed +2
-24
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package buildinfo
33import (
44 "fmt"
55 "runtime/debug"
6- "strings"
76 "sync"
87 "time"
98
@@ -61,25 +60,11 @@ func Version() string {
6160func VersionsMatch (v1 , v2 string ) bool {
6261 // Developer versions are disregarded...hopefully they know what they are
6362 // doing.
64- if strings . HasPrefix (v1 , develPrefix ) || strings . HasPrefix (v2 , develPrefix ) {
63+ if semver . Prerelease (v1 ) != "" || semver . Prerelease (v2 ) != "" {
6564 return true
6665 }
6766
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
8368}
8469
8570// 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) {
4848 v2 : "v1.2.3" ,
4949 expectMatch : true ,
5050 },
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- },
5851 // Test that we return true if a developer version is detected.
5952 // Developers do not need to be warned of mismatched versions.
6053 {
You can’t perform that action at this time.
0 commit comments