@@ -253,13 +253,19 @@ func Latest(plugin plugins.Plugin, query string) (version string, err error) {
253
253
return version , err
254
254
}
255
255
256
- allVersions , err := AllVersionsFiltered (plugin , query )
256
+ allVersions , err := AllVersions (plugin )
257
257
if err != nil {
258
258
return version , err
259
259
}
260
260
261
- versions := filterOutByRegex (allVersions , numericStartFilterRegex , true )
262
- versions = filterOutByRegex (versions , latestFilterRegex , false )
261
+ versions := filterByRegex (allVersions , latestFilterRegex , false )
262
+
263
+ // If no query specified by user default to selecting version with numeric start
264
+ if query == "" {
265
+ versions = filterByRegex (versions , numericStartFilterRegex , true )
266
+ } else {
267
+ versions = filterByExactMatch (versions , query )
268
+ }
263
269
264
270
if len (versions ) < 1 {
265
271
return version , errors .New (noLatestVersionErrMsg )
@@ -284,17 +290,6 @@ func AllVersions(plugin plugins.Plugin) (versions []string, err error) {
284
290
return versions , err
285
291
}
286
292
287
- // AllVersionsFiltered returns a list of existing versions that match a regex
288
- // query provided by the user.
289
- func AllVersionsFiltered (plugin plugins.Plugin , query string ) (versions []string , err error ) {
290
- all , err := AllVersions (plugin )
291
- if err != nil {
292
- return versions , err
293
- }
294
-
295
- return filterByExactMatch (all , query ), err
296
- }
297
-
298
293
// Uninstall uninstalls a specific tool version. It invokes pre and
299
294
// post-uninstall hooks if set, and runs the plugin's uninstall callback if
300
295
// defined.
@@ -349,7 +344,7 @@ func filterByExactMatch(allVersions []string, pattern string) (versions []string
349
344
return versions
350
345
}
351
346
352
- func filterOutByRegex (allVersions []string , pattern string , keepMatch bool ) (versions []string ) {
347
+ func filterByRegex (allVersions []string , pattern string , keepMatch bool ) (versions []string ) {
353
348
regex , _ := regexp .Compile (pattern )
354
349
for _ , version := range allVersions {
355
350
match := regex .MatchString (version )
0 commit comments