diff --git a/pkg/cmd/codespace/rebuild.go b/pkg/cmd/codespace/rebuild.go index 56e841dfe..9988f196a 100644 --- a/pkg/cmd/codespace/rebuild.go +++ b/pkg/cmd/codespace/rebuild.go @@ -34,8 +34,7 @@ func (a *App) Rebuild(ctx context.Context, codespaceName string) (err error) { return err } - // Users can't change their codespace while it's rebuilding, so there's - // no need to execute this command. + // There's no need to rebuild again because users can't modify their codespace while it rebuilds if codespace.State == api.CodespaceStateRebuilding { fmt.Fprintf(a.io.Out, "%s is already rebuilding\n", codespace.Name) return nil @@ -43,13 +42,13 @@ func (a *App) Rebuild(ctx context.Context, codespaceName string) (err error) { session, err := startLiveShareSession(ctx, codespace, a, false, "") if err != nil { - return err + return fmt.Errorf("starting Live Share session: %w", err) } defer safeClose(session, &err) err = session.Rebuild(ctx) if err != nil { - return fmt.Errorf("couldn't rebuild codespace: %w", err) + return fmt.Errorf("rebuilding codespace via session: %w", err) } fmt.Fprintf(a.io.Out, "%s is rebuilding\n", codespace.Name) diff --git a/pkg/cmd/codespace/rebuild_test.go b/pkg/cmd/codespace/rebuild_test.go index effaae28d..bb268efee 100644 --- a/pkg/cmd/codespace/rebuild_test.go +++ b/pkg/cmd/codespace/rebuild_test.go @@ -13,7 +13,7 @@ func TestAlreadyRebuildingCodespace(t *testing.T) { err := app.Rebuild(context.Background(), "rebuildingCodespace") if err != nil { - t.Errorf("error rebuilding a codespace that is already rebuilding: %v", err) + t.Errorf("rebuilding a codespace that was already rebuilding: %v", err) } } diff --git a/pkg/liveshare/session.go b/pkg/liveshare/session.go index 8518afd56..99f82af99 100644 --- a/pkg/liveshare/session.go +++ b/pkg/liveshare/session.go @@ -124,13 +124,13 @@ func (s *Session) StartJupyterServer(ctx context.Context) (int, string, error) { } func (s *Session) Rebuild(ctx context.Context) error { - var success bool - err := s.rpc.do(ctx, "IEnvironmentConfigurationService.rebuildContainer", []string{}, &success) + var rebuildSuccess bool + err := s.rpc.do(ctx, "IEnvironmentConfigurationService.rebuildContainer", []string{}, &rebuildSuccess) if err != nil { return fmt.Errorf("invoking rebuild RPC: %w", err) } - if !success { + if !rebuildSuccess { return fmt.Errorf("couldn't rebuild codespace") } else { return nil diff --git a/pkg/liveshare/session_test.go b/pkg/liveshare/session_test.go index 2160caf6e..1af35b2e0 100644 --- a/pkg/liveshare/session_test.go +++ b/pkg/liveshare/session_test.go @@ -413,7 +413,7 @@ func TestRebuild(t *testing.T) { err = session.Rebuild(context.Background()) if err != nil { - t.Fatalf("rebuilding codespace over mock session: %v", err) + t.Fatalf("rebuilding codespace via mock session: %v", err) } }