MCPcopy
hub / github.com/cli/cli / editRun

Function editRun

pkg/cmd/issue/edit/edit.go:250–458  ·  view source on GitHub ↗
(opts *EditOptions)

Source from the content-addressed store, hash-verified

248}
249
250func editRun(opts *EditOptions) error {
251 httpClient, err := opts.HttpClient()
252 if err != nil {
253 return err
254 }
255
256 baseRepo, err := opts.BaseRepo()
257 if err != nil {
258 return err
259 }
260
261 // Prompt the user which fields they'd like to edit.
262 editable := opts.Editable
263 editable.IssueType.Selectable = true
264 if opts.Interactive {
265 err = opts.FieldsToEditSurvey(opts.Prompter, &editable)
266 if err != nil {
267 return err
268 }
269 }
270
271 if opts.Detector == nil {
272 cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
273 opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost())
274 }
275
276 issueFeatures, err := opts.Detector.IssueFeatures()
277 if err != nil {
278 return err
279 }
280
281 lookupFields := []string{"id", "number", "title", "body", "url"}
282 if editable.Assignees.Edited {
283 // TODO ApiActorsSupported
284 if issueFeatures.ApiActorsSupported {
285 editable.ApiActorsSupported = true
286 lookupFields = append(lookupFields, "assignedActors")
287 } else {
288 lookupFields = append(lookupFields, "assignees")
289 }
290 }
291 if editable.Labels.Edited {
292 lookupFields = append(lookupFields, "labels")
293 }
294 if editable.Projects.Edited {
295 // TODO projectsV1Deprecation
296 // Remove this section as we should no longer add projectCards
297 projectsV1Support := opts.Detector.ProjectsV1()
298 if projectsV1Support == gh.ProjectsV1Supported {
299 lookupFields = append(lookupFields, "projectCards")
300 }
301
302 lookupFields = append(lookupFields, "projectItems")
303 }
304 if editable.Milestone.Edited {
305 lookupFields = append(lookupFields, "milestone")
306 }
307 if editable.IssueType.Edited {

Callers 5

Test_editRunFunction · 0.70
TestApiActorsSupportedFunction · 0.70
NewCmdEditFunction · 0.70

Calls 15

NewCachedHTTPClientFunction · 0.92
NewClientFromHTTPFunction · 0.92
DeferredUpdateIssueFunction · 0.92
PluralizeFunction · 0.92
lookupIssueTypeIDFunction · 0.85
NamesMethod · 0.80
ProjectNamesMethod · 0.80
ProjectTitlesMethod · 0.80
BaseRepoMethod · 0.65
RepoHostMethod · 0.65
IssueFeaturesMethod · 0.65

Tested by 4

Test_editRunFunction · 0.56
TestApiActorsSupportedFunction · 0.56