From 4d86229092d5f0480080d8f1cb22edd150b84768 Mon Sep 17 00:00:00 2001 From: Miguel Victoria Villaquiran Date: Fri, 18 Oct 2024 17:42:51 +0200 Subject: [PATCH] fix(gnovm): remove migration code of old GNOHOME (#2978) closes #800
Contributors' checklist... - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests
--- gnovm/pkg/gnoenv/gnohome.go | 2 -- gnovm/pkg/gnoenv/migration.go | 28 ---------------------------- gnovm/pkg/gnoenv/migration_test.go | 29 ----------------------------- 3 files changed, 59 deletions(-) delete mode 100644 gnovm/pkg/gnoenv/migration.go delete mode 100644 gnovm/pkg/gnoenv/migration_test.go diff --git a/gnovm/pkg/gnoenv/gnohome.go b/gnovm/pkg/gnoenv/gnohome.go index 52dd5e6adb4..9e0f1bab689 100644 --- a/gnovm/pkg/gnoenv/gnohome.go +++ b/gnovm/pkg/gnoenv/gnohome.go @@ -29,7 +29,5 @@ func HomeDir() string { } gnoHome := filepath.Join(dir, "gno") - // XXX: added april 2023 as a transitory measure - remove after test4 - fixOldDefaultGnoHome(gnoHome) return gnoHome } diff --git a/gnovm/pkg/gnoenv/migration.go b/gnovm/pkg/gnoenv/migration.go deleted file mode 100644 index 5b1d1fd1fa0..00000000000 --- a/gnovm/pkg/gnoenv/migration.go +++ /dev/null @@ -1,28 +0,0 @@ -package gnoenv - -import ( - "log" - "os" - "path/filepath" -) - -// XXX: added april 2023 as a transitory measure - remove after test4 -func fixOldDefaultGnoHome(newDir string) { - dir, err := os.UserHomeDir() - if err != nil { - return - } - oldDir := filepath.Join(dir, ".gno") - s, err := os.Stat(oldDir) - if err != nil || !s.IsDir() { - return - } - if err = os.Rename(oldDir, newDir); err != nil { - if os.IsExist(err) { - log.Printf("WARNING: attempted moving old default GNO_HOME (%q) to new (%q) but failed because directory exists.", oldDir, newDir) - log.Printf("You may need to move files from the old directory manually, or set the env var GNO_HOME to %q to retain the old directory.", oldDir) - } else { - log.Printf("WARNING: attempted moving old default GNO_HOME (%q) to new (%q) but failed with error: %v", oldDir, newDir, err) - } - } -} diff --git a/gnovm/pkg/gnoenv/migration_test.go b/gnovm/pkg/gnoenv/migration_test.go deleted file mode 100644 index 86edd8502a1..00000000000 --- a/gnovm/pkg/gnoenv/migration_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package gnoenv - -import ( - "os" - "path/filepath" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestFixOldDefaultGnoHome(t *testing.T) { - tempHomeDir := t.TempDir() - t.Setenv("HOME", tempHomeDir) - - oldGnoHome := filepath.Join(tempHomeDir, ".gno") - newGnoHome := filepath.Join(tempHomeDir, "gno") - - // Create a dummy old GNO_HOME - os.Mkdir(oldGnoHome, 0o755) - - // Test migration - fixOldDefaultGnoHome(newGnoHome) - - _, errOld := os.Stat(oldGnoHome) - require.NotNil(t, errOld) - _, errNew := os.Stat(newGnoHome) - require.True(t, os.IsNotExist(errOld), "invalid errors", errOld) - require.NoError(t, errNew) -}