@@ -5,19 +5,13 @@ import (
55 "errors"
66 "fmt"
77 "strings"
8- "time"
98
109 "github.com/bitrise-io/bitrise/v2/toolprovider/mise/execenv"
1110 "github.com/bitrise-io/bitrise/v2/toolprovider/provider"
1211)
1312
1413var errNoMatchingVersion = errors .New ("no matching version found" )
1514
16- // MiseExecutor defines the interface for executing mise commands
17- type MiseExecutor interface {
18- RunMiseWithTimeout (timeout time.Duration , args ... string ) (string , error )
19- }
20-
2115func (m * MiseToolProvider ) resolveToConcreteVersionAfterInstall (tool provider.ToolRequest ) (string , error ) {
2216 // Mise doesn't tell us what version it resolved to when installing the user-provided (and potentially fuzzy) version.
2317 // But we can use `mise latest` to find out the concrete version.
@@ -35,12 +29,12 @@ func (m *MiseToolProvider) resolveToConcreteVersionAfterInstall(tool provider.To
3529}
3630
3731func (m * MiseToolProvider ) resolveToLatestReleased (toolName provider.ToolID , version string ) (string , error ) {
38- return resolveToLatestReleased (& m .ExecEnv , toolName , version )
32+ return resolveToLatestReleased (m .ExecEnv , toolName , version )
3933}
4034
41- func resolveToLatestReleased (executor MiseExecutor , toolName provider.ToolID , version string ) (string , error ) {
35+ func resolveToLatestReleased (execEnv execenv. ExecEnv , toolName provider.ToolID , version string ) (string , error ) {
4236 // Even if version is empty string "sometool@" will not cause an error.
43- output , err := executor .RunMiseWithTimeout (execenv .DefaultTimeout , "latest" , fmt .Sprintf ("%s@%s" , toolName , version ))
37+ output , err := execEnv .RunMiseWithTimeout (execenv .DefaultTimeout , "latest" , fmt .Sprintf ("%s@%s" , toolName , version ))
4438 if err != nil {
4539 return "" , fmt .Errorf ("mise latest %s@%s: %w" , toolName , version , err )
4640 }
@@ -54,18 +48,18 @@ func resolveToLatestReleased(executor MiseExecutor, toolName provider.ToolID, ve
5448}
5549
5650func (m * MiseToolProvider ) resolveToLatestInstalled (toolName provider.ToolID , version string ) (string , error ) {
57- return resolveToLatestInstalled (& m .ExecEnv , toolName , version )
51+ return resolveToLatestInstalled (m .ExecEnv , toolName , version )
5852}
5953
60- func resolveToLatestInstalled (executor MiseExecutor , toolName provider.ToolID , version string ) (string , error ) {
54+ func resolveToLatestInstalled (execEnv execenv. ExecEnv , toolName provider.ToolID , version string ) (string , error ) {
6155 // Even if version is empty string "sometool@" will not cause an error.
6256 var toolString = string (toolName )
6357 if version != "" && version != "installed" {
6458 // tool@installed is not valid, so only append version when it's not "installed"
6559 toolString = fmt .Sprintf ("%s@%s" , toolName , version )
6660 }
6761
68- output , err := executor .RunMiseWithTimeout (execenv .DefaultTimeout , "latest" , "--installed" , "--quiet" , toolString )
62+ output , err := execEnv .RunMiseWithTimeout (execenv .DefaultTimeout , "latest" , "--installed" , "--quiet" , toolString )
6963 if err != nil {
7064 return "" , fmt .Errorf ("mise latest --installed %s: %w" , toolString , err )
7165 }
@@ -79,13 +73,13 @@ func resolveToLatestInstalled(executor MiseExecutor, toolName provider.ToolID, v
7973}
8074
8175func (m * MiseToolProvider ) versionExists (toolName provider.ToolID , version string ) (bool , error ) {
82- return versionExists (& m .ExecEnv , toolName , version )
76+ return versionExists (m .ExecEnv , toolName , version )
8377}
8478
85- func versionExists (executor MiseExecutor , toolName provider.ToolID , version string ) (bool , error ) {
79+ func versionExists (execEnv execenv. ExecEnv , toolName provider.ToolID , version string ) (bool , error ) {
8680 if version == "installed" {
8781 // List all installed versions to see if there is at least one version available.
88- output , err := executor .RunMiseWithTimeout (execenv .DefaultTimeout , "ls" , "--installed" , "--json" , "--quiet" , string (toolName ))
82+ output , err := execEnv .RunMiseWithTimeout (execenv .DefaultTimeout , "ls" , "--installed" , "--json" , "--quiet" , string (toolName ))
8983 if err != nil {
9084 return false , fmt .Errorf ("mise ls --installed %s: %w" , toolName , err )
9185 }
@@ -113,7 +107,7 @@ func versionExists(executor MiseExecutor, toolName provider.ToolID, version stri
113107 // - it can return multiple versions (one per line) when a fuzzy version is provided
114108 // - in case of no matching version, the exit code is still 0, just there is no output
115109 // - in case of a non-existing tool, the exit code is 1, but a non-existing tool ID fails earlier than this check
116- output , err := executor .RunMiseWithTimeout (execenv .DefaultTimeout , "ls-remote" , "--quiet" , versionString )
110+ output , err := execEnv .RunMiseWithTimeout (execenv .DefaultTimeout , "ls-remote" , "--quiet" , versionString )
117111 if err != nil {
118112 return false , fmt .Errorf ("mise ls-remote %s: %w" , versionString , err )
119113 }
0 commit comments