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

Method DisplayNames

api/queries_issue.go:161–200  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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