Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better logs when running implicit setup; do minimal setup only #999

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions bitrise/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions configs/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions configs/configs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}