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

Function editRun

pkg/cmd/pr/edit/edit.go:285–455  ·  view source on GitHub ↗
(opts *EditOptions)

Source from the content-addressed store, hash-verified

283}
284
285func editRun(opts *EditOptions) error {
286 httpClient, err := opts.HttpClient()
287 if err != nil {
288 return err
289 }
290
291 if opts.Detector == nil {
292 baseRepo, err := opts.BaseRepo()
293 if err != nil {
294 return err
295 }
296
297 cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
298 opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost())
299 }
300
301 findOptions := shared.FindOptions{
302 Selector: opts.SelectorArg,
303 Fields: []string{"id", "author", "url", "title", "body", "baseRefName", "reviewRequests", "labels", "projectCards", "projectItems", "milestone"},
304 Detector: opts.Detector,
305 }
306
307 if len(opts.Assets) > 0 {
308 findOptions.Fields = append(findOptions.Fields, "repository")
309 }
310
311 issueFeatures, err := opts.Detector.IssueFeatures()
312 if err != nil {
313 return err
314 }
315
316 // TODO ApiActorsSupported
317 if issueFeatures.ApiActorsSupported {
318 findOptions.Fields = append(findOptions.Fields, "assignedActors")
319 } else {
320 findOptions.Fields = append(findOptions.Fields, "assignees")
321 }
322
323 pr, repo, err := opts.Finder.Find(findOptions)
324 if err != nil {
325 return err
326 }
327
328 // Built before the prompts, so a run that cannot upload stops early.
329 var uploader *attachments.Uploader
330 if len(opts.Assets) > 0 {
331 cfg, err := opts.Config()
332 if err != nil {
333 return err
334 }
335 // A URL selector names its own host, so this can differ from the
336 // default host.
337 host := repo.RepoHost()
338 tokenType := cfg.Authentication().ActiveTokenType(host)
339 uploader, err = attachments.NewUploader(httpClient, tokenType, host, pr.RepositoryDatabaseID(), pr.RepositoryViewerPermission())
340 if err != nil {
341 return err
342 }

Callers 3

Test_editRunFunction · 0.70
NewCmdEditFunction · 0.70

Calls 15

UploadAndAttachMethod · 0.95
NewCachedHTTPClientFunction · 0.92
NewUploaderFunction · 0.92
NewClientFromHTTPFunction · 0.92
AssigneeSearchFuncFunction · 0.92
NewStringSetFunction · 0.92
reviewerSearchFuncFunction · 0.85
NamesMethod · 0.80
ProjectNamesMethod · 0.80
ProjectTitlesMethod · 0.80
AddValuesMethod · 0.80
DirtyMethod · 0.80

Tested by 2

Test_editRunFunction · 0.56