MCPcopy Create free account
hub / github.com/cli/cli / Remotes

Method Remotes

git/client.go:158–187  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

156}
157
158func (c *Client) Remotes(ctx context.Context) (RemoteSet, error) {
159 remoteArgs := []string{"remote", "-v"}
160 remoteCmd, err := c.Command(ctx, remoteArgs...)
161 if err != nil {
162 return nil, err
163 }
164 remoteOut, remoteErr := remoteCmd.Output()
165 if remoteErr != nil {
166 return nil, remoteErr
167 }
168
169 configArgs := []string{"config", "--get-regexp", `^remote\..*\.gh-resolved$`}
170 configCmd, err := c.Command(ctx, configArgs...)
171 if err != nil {
172 return nil, err
173 }
174 configOut, configErr := configCmd.Output()
175 if configErr != nil {
176 // Ignore exit code 1 as it means there are no resolved remotes.
177 var gitErr *GitError
178 if ok := errors.As(configErr, &gitErr); ok && gitErr.ExitCode != 1 {
179 return nil, gitErr
180 }
181 }
182
183 remotes := parseRemotes(outputLines(remoteOut))
184 populateResolvedRemotes(remotes, outputLines(configOut))
185 sort.Sort(remotes)
186 return remotes, nil
187}
188
189func (c *Client) UpdateRemoteURL(ctx context.Context, name, url string) error {
190 args := []string{"remote", "set-url", name, url}

Callers

nothing calls this directly

Calls 5

CommandMethod · 0.95
parseRemotesFunction · 0.85
outputLinesFunction · 0.85
populateResolvedRemotesFunction · 0.85
OutputMethod · 0.65

Tested by

no test coverage detected