From 31cdb6fa4cadc1641148ef6cebf2359276d7672f Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Thu, 20 Feb 2020 20:07:10 -0800 Subject: [PATCH] Check to see if the migration has already happened --- internal/indexmigration/migration.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/indexmigration/migration.go b/internal/indexmigration/migration.go index 8403bb6c..422ffc9b 100644 --- a/internal/indexmigration/migration.go +++ b/internal/indexmigration/migration.go @@ -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" @@ -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