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

Drop the commit progress spinner, instead everything is handled under "solve" #3459

Merged
merged 6 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions internal/output/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func (d *Spinner) MarshalOutput(f Format) interface{} {
}

func StartSpinner(out Outputer, msg string, interval time.Duration) *Spinner {
frames := []string{".", "..", "..."}
frames := []string{"."}
if out.Config().Interactive {
frames = []string{`|`, `/`, `-`, `\`}
frames = SpinnerFrames
}
d := &Spinner{0, frames, out, make(chan struct{}, 1), interval, false}

Expand Down
12 changes: 4 additions & 8 deletions internal/runbits/runtime/requirements/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (r *RequirementOperation) ExecuteRequirementOperation(ts *time.Time, requir
}
hasParentCommit := parentCommitID != ""

pg = output.StartSpinner(out, locale.T("progress_commit"), constants.TerminalAnimationInterval)
pg = output.StartSpinner(r.Output, locale.T("progress_solve_preruntime"), constants.TerminalAnimationInterval)

if err := r.checkForUpdate(parentCommitID, requirements...); err != nil {
return locale.WrapError(err, "err_check_for_update", "Could not check for requirements updates")
Expand Down Expand Up @@ -214,16 +214,11 @@ func (r *RequirementOperation) ExecuteRequirementOperation(ts *time.Time, requir
}

// Solve runtime
solveSpinner := output.StartSpinner(r.Output, locale.T("progress_solve_preruntime"), constants.TerminalAnimationInterval)
commit, err := bp.StageCommit(params)
if err != nil {
solveSpinner.Stop(locale.T("progress_fail"))
return errs.Wrap(err, "Could not stage commit")
}

pg.Stop(locale.T("progress_success"))
pg = nil

ns := requirements[0].Namespace
var trig trigger.Trigger
switch ns.Type() {
Expand All @@ -237,10 +232,11 @@ func (r *RequirementOperation) ExecuteRequirementOperation(ts *time.Time, requir

oldCommit, err := bp.FetchCommit(parentCommitID, r.Project.Owner(), r.Project.Name(), nil)
if err != nil {
solveSpinner.Stop(locale.T("progress_fail"))
return errs.Wrap(err, "Failed to fetch old build result")
}
solveSpinner.Stop(locale.T("progress_success"))

pg.Stop(locale.T("progress_success"))
pg = nil

dependencies.OutputChangeSummary(r.prime.Output(), commit.BuildPlan(), oldCommit.BuildPlan())

Expand Down
12 changes: 4 additions & 8 deletions internal/runners/packages/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (i *Import) Run(params *ImportRunParams) (rerr error) {
return locale.WrapError(err, "err_import_language", "Unable to get language from project")
}

pg := output.StartSpinner(out, locale.T("progress_commit"), constants.TerminalAnimationInterval)
pg := output.StartSpinner(i.prime.Output(), locale.T("progress_solve_preruntime"), constants.TerminalAnimationInterval)
defer func() {
if pg != nil {
pg.Stop(locale.T("progress_fail"))
Expand All @@ -125,7 +125,6 @@ func (i *Import) Run(params *ImportRunParams) (rerr error) {
return locale.WrapError(err, "err_cannot_apply_changeset", "Could not apply changeset")
}

solveSpinner := output.StartSpinner(i.prime.Output(), locale.T("progress_solve_preruntime"), constants.TerminalAnimationInterval)
msg := locale.T("commit_reqstext_message")
stagedCommit, err := bp.StageCommit(buildplanner.StageCommitParams{
Owner: proj.Owner(),
Expand All @@ -137,24 +136,21 @@ func (i *Import) Run(params *ImportRunParams) (rerr error) {
// Always update the local commit ID even if the commit fails to build
if stagedCommit != nil && stagedCommit.Commit != nil && stagedCommit.Commit.CommitID != "" {
if err := localcommit.Set(proj.Dir(), stagedCommit.CommitID.String()); err != nil {
solveSpinner.Stop(locale.T("progress_fail"))
return locale.WrapError(err, "err_package_update_commit_id")
}
pg.Stop(locale.T("progress_success"))
pg = nil
}
if err != nil {
solveSpinner.Stop(locale.T("progress_fail"))
return locale.WrapError(err, "err_commit_changeset", "Could not commit import changes")
}

// Output change summary.
previousCommit, err := bp.FetchCommit(localCommitId, proj.Owner(), proj.Name(), nil)
if err != nil {
solveSpinner.Stop(locale.T("progress_fail"))
return errs.Wrap(err, "Failed to fetch build result for previous commit")
}
solveSpinner.Stop(locale.T("progress_success"))

pg.Stop(locale.T("progress_success"))
pg = nil

dependencies.OutputChangeSummary(i.prime.Output(), stagedCommit.BuildPlan(), previousCommit.BuildPlan())

Expand Down
Loading