Skip to content

Commit

Permalink
Revert PreUse hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Chance-fyi committed Jul 26, 2024
1 parent bf3739c commit 634247e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions internal/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ func (b *Sdk) PreUse(version Version, scope UseScope) (Version, error) {
// not want to change the version or not implement the PreUse function.
// We can simply fuzzy match the version based on the input version.
if newVersion == "" {
// Before fuzzy matching, perform exact matching first.
if b.CheckExists(version) {
return version, nil
}
installedVersions := make(util.VersionSort, 0, len(installedSdks))
for _, sdk := range installedSdks {
installedVersions = append(installedVersions, string(sdk.Main.Version))
Expand Down Expand Up @@ -360,16 +364,14 @@ func (b *Sdk) PreUse(version Version, scope UseScope) (Version, error) {
func (b *Sdk) Use(version Version, scope UseScope) error {
logger.Debugf("Use SDK version: %s, scope:%v\n", string(version), scope)

version, err := b.PreUse(version, scope)
if err != nil {
return err
}

label := b.label(version)
if !b.CheckExists(version) {
v, err := b.PreUse(version, scope)
if err != nil {
return err
}
version = v
label := b.label(version)
if !b.CheckExists(version) {
return fmt.Errorf("%s is not installed", label)
}
return fmt.Errorf("%s is not installed", label)
}

if !env.IsHookEnv() {
Expand Down

0 comments on commit 634247e

Please sign in to comment.