MCPcopy
hub / github.com/cli/cli / AssigneeIds

Method AssigneeIds

pkg/cmd/pr/shared/editable.go:105–149  ·  view source on GitHub ↗
(client *api.Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

103}
104
105func (e Editable) AssigneeIds(client *api.Client, repo ghrepo.Interface) (*[]string, error) {
106 if !e.Assignees.Edited {
107 return nil, nil
108 }
109
110 // If assignees came in from command line flags, we need to
111 // curate the final list of assignees from the default list.
112 if len(e.Assignees.Add) != 0 || len(e.Assignees.Remove) != 0 {
113 // TODO ApiActorsSupported
114 replacer := NewSpecialAssigneeReplacer(client, repo.RepoHost(), e.ApiActorsSupported, true)
115
116 assigneeSet := set.NewStringSet()
117
118 // This check below is required because in a non-interactive flow,
119 // the user gives us a login and not the DisplayName, and when
120 // we have actor assignees e.Assignees.Default will contain
121 // DisplayNames and not logins (this is to accommodate special actor
122 // display names in the interactive flow).
123 // So, we need to add the default logins here instead of the DisplayNames.
124 // Otherwise, the value the user provided won't be found in the
125 // set to be added or removed, causing unexpected behavior.
126 // TODO ApiActorsSupported
127 if e.ApiActorsSupported {
128 assigneeSet.AddValues(e.Assignees.DefaultLogins)
129 } else {
130 assigneeSet.AddValues(e.Assignees.Default)
131 }
132
133 add, err := replacer.ReplaceSlice(e.Assignees.Add)
134 if err != nil {
135 return nil, err
136 }
137 assigneeSet.AddValues(add)
138
139 remove, err := replacer.ReplaceSlice(e.Assignees.Remove)
140 if err != nil {
141 return nil, err
142 }
143 assigneeSet.RemoveValues(remove)
144
145 e.Assignees.Value = assigneeSet.ToSlice()
146 }
147 a, err := e.Metadata.MembersToIDs(e.Assignees.Value)
148 return &a, err
149}
150
151// AssigneeLogins computes the final list of assignee logins from the current
152// defaults plus any Add/Remove operations. Unlike AssigneeIds, this does not

Callers 1

replaceIssueFieldsFunction · 0.80

Calls 8

ReplaceSliceMethod · 0.95
NewStringSetFunction · 0.92
AddValuesMethod · 0.80
RemoveValuesMethod · 0.80
MembersToIDsMethod · 0.80
RepoHostMethod · 0.65
ToSliceMethod · 0.65

Tested by

no test coverage detected