Skip to content

Commit

Permalink
Check to see if the migration has already happened
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskim06 committed Feb 21, 2020
1 parent e12915d commit 31cdb6f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/indexmigration/migration.go
Expand Up @@ -17,6 +17,7 @@ package indexmigration
import (
"os"

"k8s.io/klog"
"sigs.k8s.io/krew/internal/environment"
"sigs.k8s.io/krew/internal/gitutil"
"sigs.k8s.io/krew/pkg/constants"
Expand All @@ -36,6 +37,15 @@ func Done(paths environment.Paths) (bool, error) {

// Migrate removes the index directory and then clones krew-index to the new default index path.
func Migrate(paths environment.Paths) error {
isMigrated, err := Done(paths)
if err != nil {
return err
}
if isMigrated {
klog.Infoln("Already migrated")
return nil
}

err := os.RemoveAll(paths.IndexPath())
if err != nil {
return err
Expand Down

0 comments on commit 31cdb6f

Please sign in to comment.