diff --git a/internal/runners/install/install.go b/internal/runners/install/install.go index e11ca22eed..5724c7b580 100644 --- a/internal/runners/install/install.go +++ b/internal/runners/install/install.go @@ -114,7 +114,6 @@ func (i *Install) Run(params Params) (rerr error) { var oldCommit *bpModel.Commit var reqs requirements var ts time.Time - var override bool { pg = output.StartSpinner(out, locale.T("progress_search"), constants.TerminalAnimationInterval) @@ -134,7 +133,6 @@ func (i *Install) Run(params Params) (rerr error) { if err != nil { return errs.Wrap(err, "Unable to get timestamp from params") } - override = params.Timestamp.String() != "" // Get languages used in current project languages, err := model.FetchLanguagesForBuildScript(oldCommit.BuildScript()) @@ -155,7 +153,7 @@ func (i *Install) Run(params Params) (rerr error) { // Prepare updated buildscript script := oldCommit.BuildScript() - if err := prepareBuildScript(script, reqs, ts, override); err != nil { + if err := prepareBuildScript(script, reqs, ts); err != nil { return errs.Wrap(err, "Could not prepare build script") } @@ -342,8 +340,8 @@ func (i *Install) renderUserFacing(reqs requirements) { i.prime.Output().Notice("") } -func prepareBuildScript(script *buildscript.BuildScript, requirements requirements, ts time.Time, override bool) error { - script.SetAtTime(ts, override) +func prepareBuildScript(script *buildscript.BuildScript, requirements requirements, ts time.Time) error { + script.SetAtTime(ts, true) for _, req := range requirements { requirement := types.Requirement{ Namespace: req.Resolved.Namespace, diff --git a/internal/runners/platforms/add.go b/internal/runners/platforms/add.go index 5b4d7b4300..3c194ff96f 100644 --- a/internal/runners/platforms/add.go +++ b/internal/runners/platforms/add.go @@ -98,7 +98,7 @@ func (a *Add) Run(params AddRunParams) (rerr error) { // Prepare updated buildscript script := oldCommit.BuildScript() - script.SetAtTime(ts, false) + script.SetAtTime(ts, true) script.AddPlatform(*platform.PlatformID) // Update local checkout and source runtime changes diff --git a/internal/runners/upgrade/upgrade.go b/internal/runners/upgrade/upgrade.go index ec1320542d..eb82b499c2 100644 --- a/internal/runners/upgrade/upgrade.go +++ b/internal/runners/upgrade/upgrade.go @@ -111,7 +111,7 @@ func (u *Upgrade) Run(params *Params) (rerr error) { if err != nil { return errs.Wrap(err, "Failed to fetch latest timestamp") } - bumpedBS.SetAtTime(ts, params.Timestamp.String() != "") + bumpedBS.SetAtTime(ts, true) // Since our platform is commit based we need to create a commit for the "after" buildplan, even though we may not // end up using it it the user doesn't confirm the upgrade. diff --git a/pkg/buildscript/buildscript.go b/pkg/buildscript/buildscript.go index 79ad6b7474..6b118071df 100644 --- a/pkg/buildscript/buildscript.go +++ b/pkg/buildscript/buildscript.go @@ -56,6 +56,9 @@ func (b *BuildScript) AtTime() *time.Time { return b.atTime } +// SetAtTime sets the AtTime value, if the buildscript already has an AtTime value +// and `override=false` then the value passed here will be discarded. +// Override should in most cases only be true if we are making changes to the buildscript. func (b *BuildScript) SetAtTime(t time.Time, override bool) { if b.atTime != nil && !override { return