Skip to content

Commit

Permalink
fix: git provider config flag on create (#1315)
Browse files Browse the repository at this point in the history
Signed-off-by: Toma Puljak <[email protected]>
  • Loading branch information
Tpuljak authored Nov 5, 2024
1 parent 05aa014 commit 389fcdd
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions pkg/cmd/workspace/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 389fcdd

Please sign in to comment.