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

Method userOrgLogins

pkg/cmd/project/shared/queries/queries.go:1321–1357  ·  view source on GitHub ↗

userOrgLogins gets all the logins of the viewer and the organizations the viewer is a member of.

()

Source from the content-addressed store, hash-verified

1319
1320// userOrgLogins gets all the logins of the viewer and the organizations the viewer is a member of.
1321func (c *Client) userOrgLogins() ([]loginTypes, error) {
1322 l := make([]loginTypes, 0)
1323 var v viewerLoginOrgs
1324 variables := map[string]interface{}{
1325 "after": (*githubv4.String)(nil),
1326 }
1327
1328 err := c.doQueryWithProgressIndicator("ViewerLoginAndOrgs", &v, variables)
1329 if err != nil {
1330 return l, err
1331 }
1332
1333 // add the user
1334 l = append(l, loginTypes{
1335 Login: v.Viewer.Login,
1336 Type: ViewerOwner,
1337 ID: v.Viewer.ID,
1338 })
1339
1340 // add orgs where the user can create projects
1341 for _, org := range v.Viewer.Organizations.Nodes {
1342 if org.ViewerCanCreateProjects {
1343 l = append(l, loginTypes{
1344 Login: org.Login,
1345 Type: OrgOwner,
1346 ID: org.ID,
1347 })
1348 }
1349 }
1350
1351 // this seem unlikely, but if there are more org logins, paginate the rest
1352 if v.Viewer.Organizations.PageInfo.HasNextPage {
1353 return c.paginateOrgLogins(l, string(v.Viewer.Organizations.PageInfo.EndCursor))
1354 }
1355
1356 return l, nil
1357}
1358
1359// paginateOrgLogins after cursor and append them to the list of logins.
1360func (c *Client) paginateOrgLogins(l []loginTypes, cursor string) ([]loginTypes, error) {

Callers 1

NewOwnerMethod · 0.95

Calls 2

paginateOrgLoginsMethod · 0.95

Tested by

no test coverage detected