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

Method DisplayNames

api/queries_issue.go:158–197  ·  view source on GitHub ↗

DisplayNames returns a list of display names for the assigned actors.

()

Source from the content-addressed store, hash-verified

156
157// DisplayNames returns a list of display names for the assigned actors.
158func (a AssignedActors) DisplayNames() []string {
159 // These display names are used for populating the "default" assigned actors
160 // from the AssignedActors type. But, this is only one piece of the puzzle
161 // as later, other queries will fetch the full list of possible assignable
162 // actors from the repository, and the two lists will be reconciled.
163 //
164 // It's important that the display names are the same between the defaults
165 // (the values returned here) and the full list (the values returned by
166 // other repository queries). Any discrepancy would result in an
167 // "invalid default", which means an assigned actor will not be matched
168 // to an assignable actor and not presented as a "default" selection.
169 // Not being presented as a default would cause the actor to be potentially
170 // unassigned if the edits were submitted.
171 //
172 // To prevent this, we need shared logic to look up an actor's display name.
173 // However, our API types between assignedActors and the full list of
174 // assignableActors are different. So, as an attempt to maintain
175 // consistency we convert the assignedActors to the same types as the
176 // repository's assignableActors, treating the assignableActors DisplayName
177 // methods as the sources of truth.
178 // TODO KW: make this comment less of a wall of text if needed.
179 var displayNames []string
180 for _, a := range a.Nodes {
181 if a.TypeName == "User" {
182 u := NewAssignableUser(
183 a.ID,
184 a.Login,
185 a.Name,
186 )
187 displayNames = append(displayNames, u.DisplayName())
188 } else if a.TypeName == "Bot" {
189 b := NewAssignableBot(
190 a.ID,
191 a.Login,
192 )
193 displayNames = append(displayNames, b.DisplayName())
194 }
195 }
196 return displayNames
197}
198
199type Labels struct {
200 Nodes []IssueLabel

Callers 2

editRunFunction · 0.45
editRunFunction · 0.45

Calls 4

DisplayNameMethod · 0.95
DisplayNameMethod · 0.95
NewAssignableUserFunction · 0.85
NewAssignableBotFunction · 0.85

Tested by

no test coverage detected