Skip to content

Commit

Permalink
Tidy up comments and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jungaretti committed Oct 8, 2022
1 parent 4c49fd3 commit d05cdf5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions pkg/cmd/codespace/rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,21 @@ 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
}

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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/codespace/rebuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/liveshare/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/liveshare/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit d05cdf5

Please sign in to comment.