github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/lib/repository/open.go (about) 1 package repositoryLib 2 3 import ( 4 "fmt" 5 6 git "github.com/taubyte/go-simple-git" 7 libraryI18n "github.com/taubyte/tau-cli/i18n/library" 8 websiteI18n "github.com/taubyte/tau-cli/i18n/website" 9 loginLib "github.com/taubyte/tau-cli/lib/login" 10 "github.com/taubyte/tau-cli/singletons/config" 11 "github.com/taubyte/tau-cli/states" 12 ) 13 14 func (info *Info) Open(project config.Project, url string) (*git.Repository, error) { 15 profile, err := loginLib.GetSelectedProfile() 16 if err != nil { 17 return nil, err 18 } 19 20 repositoryPath, err := info.path(project) 21 if err != nil { 22 return nil, err 23 } 24 25 if !info.isCloned(repositoryPath) { 26 switch info.Type { 27 case "website": 28 websiteI18n.Help().BeSureToCloneWebsite() 29 case "library": 30 libraryI18n.Help().BeSureToCloneLibrary() 31 } 32 return nil, fmt.Errorf("repository not cloned: `%s`", repositoryPath) 33 } 34 35 repo, err := git.New(states.Context, 36 git.Root(repositoryPath), 37 git.Author(profile.GitUsername, profile.GitEmail), 38 git.URL(url), 39 git.Token(profile.Token), 40 41 // TODO branch, this breaks things 42 // git.Branch(branch), 43 ) 44 if err != nil { 45 return nil, err 46 } 47 48 return repo, nil 49 }