Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions pkg/cmd/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/brevdev/brev-cli/pkg/cmd/completions"
"github.com/brevdev/brev-cli/pkg/cmd/start"
"github.com/brevdev/brev-cli/pkg/config"
"github.com/brevdev/brev-cli/pkg/entity"
breverrors "github.com/brevdev/brev-cli/pkg/errors"
Expand Down Expand Up @@ -95,16 +94,16 @@ func profile(personalSettingsRepo string, t *terminal.Terminal, profileStore Pro
return breverrors.WrapAndTrace(err)
}

temp := start.MakeNewWorkspaceFromURL(personalSettingsRepo)
t.Vprint(temp.GitRepo)
gitRepo := makeGitRepoFromURL(personalSettingsRepo)
t.Vprint(gitRepo)

// TODO: make sure the git repo format works!!!!!!!

_, err = profileStore.UpdateUser(user.ID, &entity.UpdateUser{
Username: user.Username,
Name: user.Name,
Email: user.Email,
BaseWorkspaceRepo: temp.GitRepo,
BaseWorkspaceRepo: gitRepo,
})
if err != nil {
return breverrors.WrapAndTrace(err)
Expand All @@ -113,3 +112,20 @@ func profile(personalSettingsRepo string, t *terminal.Terminal, profileStore Pro
t.Vprintf("Your personal config has been updated. All new instances will run this script.\n")
return nil
}

func makeGitRepoFromURL(url string) string {
if strings.Contains(url, "http") {
split := strings.Split(url, ".com/")
provider := strings.Split(split[0], "://")[1]

if strings.Contains(split[1], ".git") {
return fmt.Sprintf("%s.com:%s", provider, split[1])
} else {
return fmt.Sprintf("%s.com:%s.git", provider, split[1])
}
} else {
split := strings.Split(url, ".com:")
provider := strings.Split(split[0], "@")[1]
return fmt.Sprintf("%s.com:%s", provider, split[1])
}
}
Loading
Loading