@@ -253,13 +253,19 @@ func Latest(plugin plugins.Plugin, query string) (version string, err error) {
253253 return version , err
254254 }
255255
256- allVersions , err := AllVersionsFiltered (plugin , query )
256+ allVersions , err := AllVersions (plugin )
257257 if err != nil {
258258 return version , err
259259 }
260260
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+ }
263269
264270 if len (versions ) < 1 {
265271 return version , errors .New (noLatestVersionErrMsg )
@@ -284,17 +290,6 @@ func AllVersions(plugin plugins.Plugin) (versions []string, err error) {
284290 return versions , err
285291}
286292
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-
298293// Uninstall uninstalls a specific tool version. It invokes pre and
299294// post-uninstall hooks if set, and runs the plugin's uninstall callback if
300295// defined.
@@ -349,7 +344,7 @@ func filterByExactMatch(allVersions []string, pattern string) (versions []string
349344 return versions
350345}
351346
352- func filterOutByRegex (allVersions []string , pattern string , keepMatch bool ) (versions []string ) {
347+ func filterByRegex (allVersions []string , pattern string , keepMatch bool ) (versions []string ) {
353348 regex , _ := regexp .Compile (pattern )
354349 for _ , version := range allVersions {
355350 match := regex .MatchString (version )
0 commit comments