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

Function editRun

pkg/cmd/pr/edit/edit.go:285–449  ·  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 opts.Detector = fd.NewCachedDetector(httpClient, baseRepo.RepoHost(), time.Hour*24)
298 }
299
300 findOptions := shared.FindOptions{
301 Selector: opts.SelectorArg,
302 Fields: []string{"id", "author", "url", "title", "body", "baseRefName", "reviewRequests", "labels", "projectCards", "projectItems", "milestone"},
303 Detector: opts.Detector,
304 }
305
306 if len(opts.Assets) > 0 {
307 findOptions.Fields = append(findOptions.Fields, "repository")
308 }
309
310 issueFeatures, err := opts.Detector.IssueFeatures()
311 if err != nil {
312 return err
313 }
314
315 // TODO ApiActorsSupported
316 if issueFeatures.ApiActorsSupported {
317 findOptions.Fields = append(findOptions.Fields, "assignedActors")
318 } else {
319 findOptions.Fields = append(findOptions.Fields, "assignees")
320 }
321
322 pr, repo, err := opts.Finder.Find(findOptions)
323 if err != nil {
324 return err
325 }
326
327 // Built before the prompts, so a run that cannot upload stops early.
328 var uploader *attachments.Uploader
329 if len(opts.Assets) > 0 {
330 // A URL selector names its own host, so this can differ from the
331 // default host.
332 uploader, err = attachments.NewUploader(httpClient, repo.RepoHost(), pr.RepositoryDatabaseID(), pr.RepositoryViewerPermission())
333 if err != nil {
334 return err
335 }
336 }
337
338 editable := opts.Editable
339 editable.Reviewers.Selectable = true
340 editable.Title.Default = pr.Title
341 editable.Body.Default = pr.Body
342 editable.Base.Default = pr.BaseRefName

Callers 3

Test_editRunFunction · 0.70
NewCmdEditFunction · 0.70

Calls 15

UploadAndAttachMethod · 0.95
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
RecordOperationsMethod · 0.80
DirtyMethod · 0.80

Tested by 2

Test_editRunFunction · 0.56