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

Method AssigneeIds

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

Source from the content-addressed store, hash-verified

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