diff --git a/diagnostics/diagnostics.go b/diagnostics/diagnostics.go index 6bcd433d3..b1453db22 100644 --- a/diagnostics/diagnostics.go +++ b/diagnostics/diagnostics.go @@ -172,9 +172,9 @@ func (d *Diagnostics) CompareVersion(value string) error { if localVersion[0] < currentVersion[0] { //Major return fmt.Errorf("Warning: You are running Pilosa %s. A newer version (%s) is available: https://github.com/pilosa/pilosa/releases", d.version, value) - } else if localVersion[1] < currentVersion[1] { // Minor + } else if localVersion[1] < currentVersion[1] && localVersion[0] == currentVersion[0] { // Minor return fmt.Errorf("Warning: You are running Pilosa %s. The latest Minor release is %s: https://github.com/pilosa/pilosa/releases", d.version, value) - } else if localVersion[2] < currentVersion[2] { // Patch + } else if localVersion[2] < currentVersion[2] && localVersion[0] == currentVersion[0] && localVersion[1] == currentVersion[1] { // Patch return fmt.Errorf("There is a new patch release of Pilosa available: %s: https://github.com/pilosa/pilosa/releases", value) } diff --git a/diagnostics/diagnostics_test.go b/diagnostics/diagnostics_test.go index 6ad0cb773..8e3a7cce4 100644 --- a/diagnostics/diagnostics_test.go +++ b/diagnostics/diagnostics_test.go @@ -96,6 +96,11 @@ func TestDiagnosticsVersion_Compare(t *testing.T) { if err != nil { t.Fatalf("Versions should match") } + d.SetVersion("v1.7.0") + err = d.CompareVersion("0.7.2") + if err != nil { + t.Fatalf("Local version is greater") + } } func TestDiagnosticsVersion_Check(t *testing.T) {