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

Function SplitGithubRemote

cli/pkg/gitutil/github.go:13–31  ·  view source on GitHub ↗

SplitGithubRemote splits a GitHub remote URL into a Github account and repository name.

(remote string)

Source from the content-addressed store, hash-verified

11
12// SplitGithubRemote splits a GitHub remote URL into a Github account and repository name.
13func SplitGithubRemote(remote string) (account, repo string, ok bool) {
14 ep, err := transport.NewEndpoint(remote)
15 if err != nil {
16 return "", "", false
17 }
18
19 if ep.Host != "github.com" {
20 return "", "", false
21 }
22
23 account, repo = path.Split(ep.Path)
24 account = strings.Trim(account, "/")
25 repo = strings.TrimSuffix(repo, ".git")
26 if account == "" || repo == "" || strings.Contains(account, "/") {
27 return "", "", false
28 }
29
30 return account, repo, true
31}
32
33// NormalizeGithubRemote validates and converts a Git remote to a normalized HTTPS Github URL ending in .git.
34func NormalizeGithubRemote(remote string) (string, error) {

Callers 13

TestManagedDeployFunction · 0.92
testSelfHostedDeployFunction · 0.92
ConnectGithubFlowFunction · 0.92
githubFlowFunction · 0.92
TestPrimaryBranchChangeFunction · 0.92
GetGithubPullRequestMethod · 0.92
githubConnectCallbackMethod · 0.92
githubAuthCallbackMethod · 0.92
createRepoMethod · 0.92

Calls 1

ContainsMethod · 0.80

Tested by 5

TestManagedDeployFunction · 0.74
testSelfHostedDeployFunction · 0.74
TestPrimaryBranchChangeFunction · 0.74