Skip to content

Commit 33e4e46

Browse files
committed
Do not emit a warning when patch version ends with .99
1 parent b19e476 commit 33e4e46

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

store.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,20 @@ func (s *PHPStore) BestVersionForDir(dir string) (*Version, string, string, erro
147147
func (s *PHPStore) bestVersion(versionPrefix, source string) (*Version, string, string, error) {
148148
warning := ""
149149

150+
isPatchVersion := false
151+
pos := strings.LastIndexByte(versionPrefix, '.')
152+
if pos != strings.IndexByte(versionPrefix, '.') {
153+
if "99" == versionPrefix[pos+1:] {
154+
versionPrefix = versionPrefix[:pos]
155+
pos = strings.LastIndexByte(versionPrefix, '.')
156+
} else {
157+
isPatchVersion = true
158+
}
159+
}
160+
150161
// Check if versionPrefix is actually a patch version, if so first do an
151162
// exact match lookup and fallback to a minor version check
152-
if pos := strings.LastIndexByte(versionPrefix, '.'); pos != strings.IndexByte(versionPrefix, '.') {
163+
if isPatchVersion {
153164
// look for an exact match, the order does not matter here
154165
for _, v := range s.versions {
155166
if v.Version == versionPrefix {

store_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,15 @@ func TestBestVersion(t *testing.T) {
4646
t.Error("8.0.10 requirement should trigger a warning")
4747
}
4848
}
49+
50+
{
51+
bestVersion, _, warning, _ := store.bestVersion("8.0.99", "testing")
52+
if bestVersion == nil {
53+
t.Error("8.0.99 requirement should find a best version")
54+
} else if bestVersion.Version != "8.0.27" {
55+
t.Error("8.0.99 requirement should find 8.0.27 as best version")
56+
} else if warning != "" {
57+
t.Error("8.0.99 requirement should not trigger a warning")
58+
}
59+
}
4960
}

0 commit comments

Comments
 (0)