diff --git a/pkg/cmd/workspace/create.go b/pkg/cmd/workspace/create.go index c8c5874b1f..543a06c192 100644 --- a/pkg/cmd/workspace/create.go +++ b/pkg/cmd/workspace/create.go @@ -433,19 +433,24 @@ func processGitURL(ctx context.Context, repoUrl string, apiClient *apiclient.API return nil, err } - gitProviderConfigs, res, err := apiClient.GitProviderAPI.ListGitProvidersForUrl(context.Background(), url.QueryEscape(repoUrl)).Execute() - if err != nil { - return nil, apiclient_util.HandleErrorResponse(res, err) - } + if projectConfigurationFlags.GitProviderConfig == nil || *projectConfigurationFlags.GitProviderConfig == "" { + gitProviderConfigs, res, err := apiClient.GitProviderAPI.ListGitProvidersForUrl(context.Background(), url.QueryEscape(repoUrl)).Execute() + if err != nil { + return nil, apiclient_util.HandleErrorResponse(res, err) + } - if len(gitProviderConfigs) == 1 { - projectConfigurationFlags.GitProviderConfig = &gitProviderConfigs[0].Id - } else if len(gitProviderConfigs) > 1 { - gp := selection.GetGitProviderConfigFromPrompt(selection.GetGitProviderConfigParams{ - GitProviderConfigs: gitProviderConfigs, - ActionVerb: "Use", - }) - projectConfigurationFlags.GitProviderConfig = &gp.Id + if len(gitProviderConfigs) == 1 { + projectConfigurationFlags.GitProviderConfig = &gitProviderConfigs[0].Id + } else if len(gitProviderConfigs) > 1 { + gp := selection.GetGitProviderConfigFromPrompt(selection.GetGitProviderConfigParams{ + GitProviderConfigs: gitProviderConfigs, + ActionVerb: "Use", + }) + if gp == nil { + return nil, common.ErrCtrlCAbort + } + projectConfigurationFlags.GitProviderConfig = &gp.Id + } } project, err := workspace_util.GetCreateProjectDtoFromFlags(projectConfigurationFlags)