MCPcopy Index your code
hub / github.com/devspace-sh/devspace / GetRemote

Function GetRemote

pkg/util/git/helper.go:61–87  ·  view source on GitHub ↗

GetRemote retrieves the remote origin

(localPath string)

Source from the content-addressed store, hash-verified

59
60// GetRemote retrieves the remote origin
61func GetRemote(localPath string) (string, error) {
62 _, err := os.Stat(localPath + "/.git")
63 if err != nil {
64 return "", err
65 }
66
67 repo, err := git.PlainOpen(localPath)
68 if err != nil {
69 return "", errors.Wrap(err, "git open")
70 }
71
72 remotes, err := repo.Remotes()
73 if err != nil {
74 return "", errors.Wrap(err, "get remotes")
75 }
76
77 if len(remotes) == 0 {
78 return "", errors.Errorf("Couldn't determine git remote in %s", localPath)
79 }
80
81 urls := remotes[0].Config().URLs
82 if len(urls) == 0 {
83 return "", errors.New("No remotes found")
84 }
85
86 return urls[0], nil
87}
88
89func GetLatestVersion(repository string) (string, error) {
90 client := &http.Client{

Callers 2

TestGitCliBranchFunction · 0.85
TestGoGitFunction · 0.85

Calls 2

ConfigMethod · 0.65
ErrorfMethod · 0.45

Tested by 2

TestGitCliBranchFunction · 0.68
TestGoGitFunction · 0.68