MCPcopy Index your code
hub / github.com/cli/cli / UpdateIssue

Function UpdateIssue

pkg/cmd/pr/shared/editable_http.go:12–92  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, id string, isPR bool, options Editable)

Source from the content-addressed store, hash-verified

10)
11
12func UpdateIssue(httpClient *http.Client, repo ghrepo.Interface, id string, isPR bool, options Editable) error {
13 var wg errgroup.Group
14
15 // Labels are updated through discrete mutations to avoid having to replace the entire list of labels
16 // and risking race conditions.
17 if options.Labels.Edited {
18 if len(options.Labels.Add) > 0 {
19 wg.Go(func() error {
20 addedLabelIds, err := options.Metadata.LabelsToIDs(options.Labels.Add)
21 if err != nil {
22 return err
23 }
24 return addLabels(httpClient, id, repo, addedLabelIds)
25 })
26 }
27 if len(options.Labels.Remove) > 0 {
28 wg.Go(func() error {
29 removeLabelIds, err := options.Metadata.LabelsToIDs(options.Labels.Remove)
30 if err != nil {
31 return err
32 }
33 return removeLabels(httpClient, id, repo, removeLabelIds)
34 })
35 }
36 }
37
38 // updateIssue mutation does not support ProjectsV2 so do them in a separate request.
39 if options.Projects.Edited {
40 wg.Go(func() error {
41 apiClient := api.NewClientFromHTTP(httpClient)
42 addIds, removeIds, err := options.ProjectV2Ids()
43 if err != nil {
44 return err
45 }
46 if addIds == nil && removeIds == nil {
47 return nil
48 }
49 toAdd := make(map[string]string, len(*addIds))
50 toRemove := make(map[string]string, len(*removeIds))
51 for _, p := range *addIds {
52 toAdd[p] = id
53 }
54 for _, p := range *removeIds {
55 toRemove[p] = options.Projects.ProjectItems[p]
56 }
57 return api.UpdateProjectV2Items(apiClient, repo, toAdd, toRemove)
58 })
59 }
60
61 if dirtyExcludingLabels(options) {
62 wg.Go(func() error {
63 // updateIssue mutation does not support Actors so assignment needs to
64 // be in a separate request when our assignees are Actors.
65 // Note: this is intentionally done synchronously with updating
66 // other issue fields to ensure consistency with how legacy
67 // user assignees are handled.
68 // https://github.com/cli/cli/pull/10960#discussion_r2086725348
69 // TODO ApiActorsSupported

Callers 1

updatePullRequestFunction · 0.92

Calls 11

NewClientFromHTTPFunction · 0.92
UpdateProjectV2ItemsFunction · 0.92
addLabelsFunction · 0.85
removeLabelsFunction · 0.85
dirtyExcludingLabelsFunction · 0.85
replaceIssueFieldsFunction · 0.85
LabelsToIDsMethod · 0.80
ProjectV2IdsMethod · 0.80
AssigneeLoginsMethod · 0.80
WaitMethod · 0.65

Tested by

no test coverage detected