From 0660c714db46acad9a58f971f2a1e53fa279f28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliv=C3=A9r=20Falvai?= Date: Tue, 24 Sep 2024 11:22:50 +0200 Subject: [PATCH] Better logs when running implicit setup; do minimal setup only (#999) * Better logs when running implicit setup * Fix tests, do minimal setup * Change log level --- bitrise/setup.go | 11 ++++++++--- configs/configs.go | 6 +++--- configs/configs_test.go | 9 ++++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/bitrise/setup.go b/bitrise/setup.go index 7bedc3d43..5ac43042b 100644 --- a/bitrise/setup.go +++ b/bitrise/setup.go @@ -46,9 +46,14 @@ var PluginDependencyMap = map[string]PluginDependency{ } func RunSetupIfNeeded(logger log.Logger) error { - if !configs.CheckIsSetupWasDoneForVersion(version.VERSION) { - log.Warnf("Setup was not performed for this version of bitrise, doing it now...") - return RunSetup(logger, version.VERSION, SetupModeDefault, false) + versionMatch, setupVersion := configs.CheckIsSetupWasDoneForVersion(version.VERSION) + if setupVersion == "" { + log.Infof("No setup was done yet, running setup now...") + return RunSetup(logger, version.VERSION, SetupModeMinimal, false) + } + if !versionMatch { + log.Infof("Setup was last performed for version %s, current version is %s. Re-running setup now...", setupVersion, version.VERSION) + return RunSetup(logger, version.VERSION, SetupModeMinimal, false) } return nil } diff --git a/configs/configs.go b/configs/configs.go index dd811c107..df039edb5 100644 --- a/configs/configs.go +++ b/configs/configs.go @@ -186,12 +186,12 @@ func SavePluginUpdateCheck(plugin string) error { return saveBitriseConfig(config) } -func CheckIsSetupWasDoneForVersion(ver string) bool { +func CheckIsSetupWasDoneForVersion(ver string) (bool, string) { config, err := loadBitriseConfig() if err != nil { - return false + return false, "" } - return (config.SetupVersion == ver) + return config.SetupVersion == ver, config.SetupVersion } func SaveSetupSuccessForVersion(ver string) error { diff --git a/configs/configs_test.go b/configs/configs_test.go index ee4acedd2..f3ed7dd27 100644 --- a/configs/configs_test.go +++ b/configs/configs_test.go @@ -18,11 +18,14 @@ func TestSetupForVersionChecks(t *testing.T) { t.Setenv("HOME", fakeHomePth) - require.Equal(t, false, CheckIsSetupWasDoneForVersion("0.9.7")) + versionMatch, _ := CheckIsSetupWasDoneForVersion("0.9.7") + require.Equal(t, false, versionMatch) require.Equal(t, nil, SaveSetupSuccessForVersion("0.9.7")) - require.Equal(t, true, CheckIsSetupWasDoneForVersion("0.9.7")) + versionMatch, _ = CheckIsSetupWasDoneForVersion("0.9.7") + require.Equal(t, true, versionMatch) - require.Equal(t, false, CheckIsSetupWasDoneForVersion("0.9.8")) + versionMatch, _ = CheckIsSetupWasDoneForVersion("0.9.8") + require.Equal(t, false, versionMatch) }