MCPcopy Index your code
hub / github.com/rilldata/rill / SplitGithubRemote

Function SplitGithubRemote

admin/pkg/gitutil/gitutil.go:11–29  ·  view source on GitHub ↗

SplitGithubRemote takes a GitHub HTTPS remote URL and extracts the Github account and repository name.

(remote string)

Source from the content-addressed store, hash-verified

9
10// SplitGithubRemote takes a GitHub HTTPS remote URL and extracts the Github account and repository name.
11func SplitGithubRemote(remote string) (account, repo string, ok bool) {
12 ep, err := transport.NewEndpoint(remote)
13 if err != nil {
14 return "", "", false
15 }
16
17 if ep.Host != "github.com" {
18 return "", "", false
19 }
20
21 account, repo = path.Split(ep.Path)
22 account = strings.Trim(account, "/")
23 repo = strings.TrimSuffix(repo, ".git")
24 if account == "" || repo == "" || strings.Contains(account, "/") {
25 return "", "", false
26 }
27
28 return account, repo, true
29}

Callers 6

DeleteBranchMethod · 0.92
GetGithubInstallationMethod · 0.92
WorkMethod · 0.92
githubOptsForRemoteMethod · 0.92

Calls 1

ContainsMethod · 0.80

Tested by

no test coverage detected