MCPcopy Create free account
hub / github.com/docker/buildx / RemoteURL

Method RemoteURL

util/gitutil/gitutil.go:61–77  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

59}
60
61func (cli *GitCLI) RemoteURL(ctx context.Context) (string, error) {
62 // Try default remote based on remote tracking branch.
63 if remote, err := cli.currentRemote(ctx); err == nil && remote != "" {
64 if ru, err := cli.clean(cli.Run(ctx, "remote", "get-url", remote)); err == nil && ru != "" {
65 return bkurlutil.RedactCredentials(ru), nil
66 }
67 }
68 // Next try to get the remote URL from the origin remote first.
69 if ru, err := cli.clean(cli.Run(ctx, "remote", "get-url", "origin")); err == nil && ru != "" {
70 return bkurlutil.RedactCredentials(ru), nil
71 }
72 // If that fails, try to get the remote URL from the upstream remote.
73 if ru, err := cli.clean(cli.Run(ctx, "remote", "get-url", "upstream")); err == nil && ru != "" {
74 return bkurlutil.RedactCredentials(ru), nil
75 }
76 return "", errors.New("no remote URL found for either origin or upstream")
77}
78
79func (cli *GitCLI) FullCommit(ctx context.Context) (string, error) {
80 return cli.clean(cli.Run(ctx, "show", "--format=%H", "HEAD", "--quiet", "--"))

Callers 2

runLsFunction · 0.80
TestGitRemoteURLFunction · 0.80

Calls 4

currentRemoteMethod · 0.95
cleanMethod · 0.95
RunMethod · 0.80
NewMethod · 0.65

Tested by 1

TestGitRemoteURLFunction · 0.64