MCPcopy
hub / github.com/cli/cli / runLink

Function runLink

pkg/cmd/project/link/link.go:155–194  ·  view source on GitHub ↗
(config linkConfig)

Source from the content-addressed store, hash-verified

153}
154
155func runLink(config linkConfig) error {
156 canPrompt := config.io.CanPrompt()
157 owner, err := config.client.NewOwner(canPrompt, config.opts.owner)
158 if err != nil {
159 return err
160 }
161 config.opts.owner = owner.Login
162
163 project, err := config.client.NewProject(canPrompt, owner, config.opts.number, false)
164 if err != nil {
165 return err
166 }
167 config.opts.projectTitle = project.Title
168 config.opts.projectID = project.ID
169 if config.opts.number == 0 {
170 config.opts.number = project.Number
171 }
172
173 httpClient, err := config.httpClient()
174 if err != nil {
175 return err
176 }
177 c := api.NewClientFromHTTP(httpClient)
178
179 if config.opts.host == "" {
180 cfg, err := config.config()
181 if err != nil {
182 return err
183 }
184 host, _ := cfg.Authentication().DefaultHost()
185 config.opts.host = host
186 }
187
188 if config.opts.repo != "" {
189 return linkRepo(c, config)
190 } else if config.opts.team != "" {
191 return linkTeam(c, config)
192 }
193 return nil
194}
195
196func linkRepo(c *api.Client, config linkConfig) error {
197 repo, err := api.GitHubRepo(c, ghrepo.NewWithHost(config.opts.owner, config.opts.repo, config.opts.host))

Callers 3

NewCmdLinkFunction · 0.85
TestRunLink_RepoFunction · 0.85
TestRunLink_TeamFunction · 0.85

Calls 8

NewClientFromHTTPFunction · 0.92
linkRepoFunction · 0.85
linkTeamFunction · 0.85
CanPromptMethod · 0.80
NewOwnerMethod · 0.80
NewProjectMethod · 0.80
DefaultHostMethod · 0.65
AuthenticationMethod · 0.65

Tested by 2

TestRunLink_RepoFunction · 0.68
TestRunLink_TeamFunction · 0.68