MCPcopy
hub / github.com/cli/cli / Remotes

Method Remotes

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

Source from the content-addressed store, hash-verified

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

Callers 2

TestClientRemotesFunction · 0.95

Calls 5

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

Tested by 2

TestClientRemotesFunction · 0.76