(ctx context.Context, client *github.Client)
| 1080 | } |
| 1081 | |
| 1082 | func (s *Server) fetchReposForUser(ctx context.Context, client *github.Client) ([]*adminv1.ListGithubUserReposResponse_Repo, error) { |
| 1083 | repos := make([]*adminv1.ListGithubUserReposResponse_Repo, 0) |
| 1084 | page := 1 |
| 1085 | |
| 1086 | for { |
| 1087 | installations, httpResp, err := client.Apps.ListUserInstallations(ctx, &github.ListOptions{Page: page, PerPage: 100}) |
| 1088 | if err != nil { |
| 1089 | return nil, err |
| 1090 | } |
| 1091 | |
| 1092 | // TODO: fill in permission |
| 1093 | |
| 1094 | for _, installation := range installations { |
| 1095 | reposForInst, err := s.fetchReposForInstallation(ctx, client, *installation.ID) |
| 1096 | if err != nil { |
| 1097 | return nil, err |
| 1098 | } |
| 1099 | repos = append(repos, reposForInst...) |
| 1100 | } |
| 1101 | |
| 1102 | if httpResp.NextPage == 0 { |
| 1103 | break |
| 1104 | } |
| 1105 | page = httpResp.NextPage |
| 1106 | } |
| 1107 | |
| 1108 | return repos, nil |
| 1109 | } |
| 1110 | |
| 1111 | func (s *Server) fetchReposForInstallation(ctx context.Context, client *github.Client, instID int64) ([]*adminv1.ListGithubUserReposResponse_Repo, error) { |
| 1112 | repos := make([]*adminv1.ListGithubUserReposResponse_Repo, 0) |
no test coverage detected