MCPcopy
hub / github.com/cli/cli / updateRemote

Function updateRemote

pkg/cmd/repo/rename/rename.go:173–195  ·  view source on GitHub ↗
(repo ghrepo.Interface, renamed ghrepo.Interface, opts *RenameOptions)

Source from the content-addressed store, hash-verified

171}
172
173func updateRemote(repo ghrepo.Interface, renamed ghrepo.Interface, opts *RenameOptions) (*ghContext.Remote, error) {
174 cfg, err := opts.Config()
175 if err != nil {
176 return nil, err
177 }
178
179 protocol := cfg.GitProtocol(repo.RepoHost()).Value
180
181 remotes, err := opts.Remotes()
182 if err != nil {
183 return nil, err
184 }
185
186 remote, err := remotes.FindByRepo(repo.RepoOwner(), repo.RepoName())
187 if err != nil {
188 return nil, err
189 }
190
191 remoteURL := ghrepo.FormatRemoteURL(renamed, protocol)
192 err = opts.GitClient.UpdateRemoteURL(context.Background(), remote.Name, remoteURL)
193
194 return remote, err
195}

Callers 1

renameRunFunction · 0.85

Calls 9

FormatRemoteURLFunction · 0.92
FindByRepoMethod · 0.80
UpdateRemoteURLMethod · 0.80
ConfigMethod · 0.65
GitProtocolMethod · 0.65
RepoHostMethod · 0.65
RemotesMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65

Tested by

no test coverage detected