@@ -77,7 +77,7 @@ func create(opts *createOptions) error {
7777 return fmt .Errorf ("error getting Codespace user: %v" , userResult .Err )
7878 }
7979
80- machine , err := getMachineName (ctx , opts .machine , userResult .User , repository , locationResult .Location , apiClient )
80+ machine , err := getMachineName (ctx , opts .machine , userResult .User , repository , branch , locationResult .Location , apiClient )
8181 if err != nil {
8282 return fmt .Errorf ("error getting machine type: %v" , err )
8383 }
@@ -225,8 +225,8 @@ func getBranchName(branch string) (string, error) {
225225}
226226
227227// getMachineName prompts the user to select the machine type, or validates the machine if non-empty.
228- func getMachineName (ctx context.Context , machine string , user * api.User , repo * api.Repository , location string , apiClient * api.API ) (string , error ) {
229- skus , err := apiClient .GetCodespacesSKUs (ctx , user , repo , location )
228+ func getMachineName (ctx context.Context , machine string , user * api.User , repo * api.Repository , branch , location string , apiClient * api.API ) (string , error ) {
229+ skus , err := apiClient .GetCodespacesSKUs (ctx , user , repo , branch , location )
230230 if err != nil {
231231 return "" , fmt .Errorf ("error getting Codespace SKUs: %v" , err )
232232 }
@@ -250,6 +250,10 @@ func getMachineName(ctx context.Context, machine string, user *api.User, repo *a
250250 return "" , nil
251251 }
252252
253+ if len (skus ) == 1 {
254+ return skus [0 ].Name , nil // VS Code does not prompt for SKU if there is only one, this makes us consistent with that behavior
255+ }
256+
253257 skuNames := make ([]string , 0 , len (skus ))
254258 skuByName := make (map [string ]* api.SKU )
255259 for _ , sku := range skus {
0 commit comments