(ctx context.Context, req *adminv1.ListGithubUserReposRequest)
| 217 | } |
| 218 | |
| 219 | func (s *Server) ListGithubUserRepos(ctx context.Context, req *adminv1.ListGithubUserReposRequest) (*adminv1.ListGithubUserReposResponse, error) { |
| 220 | claims := auth.GetClaims(ctx) |
| 221 | if claims.OwnerType() != auth.OwnerTypeUser { |
| 222 | return nil, status.Error(codes.Unauthenticated, "not authenticated") |
| 223 | } |
| 224 | |
| 225 | userID := claims.OwnerID() |
| 226 | user, err := s.admin.DB.FindUser(ctx, userID) |
| 227 | if err != nil { |
| 228 | return nil, err |
| 229 | } |
| 230 | |
| 231 | // user has not authorized github app |
| 232 | if user.GithubUsername == "" { |
| 233 | return nil, status.Error(codes.Unauthenticated, "not authenticated") |
| 234 | } |
| 235 | |
| 236 | token, err := s.userAccessToken(ctx, user) |
| 237 | if err != nil { |
| 238 | return nil, err |
| 239 | } |
| 240 | |
| 241 | client := github.NewTokenClient(ctx, token) |
| 242 | |
| 243 | // use a client with user's token to get installations |
| 244 | repos, err := s.fetchReposForUser(ctx, client) |
| 245 | if err != nil { |
| 246 | return nil, err |
| 247 | } |
| 248 | |
| 249 | return &adminv1.ListGithubUserReposResponse{ |
| 250 | Repos: repos, |
| 251 | }, nil |
| 252 | } |
| 253 | |
| 254 | // CreateGithubPullRequest creates a Github PR from the specified branch to the project's primary branch. |
| 255 | func (s *Server) CreateGithubPullRequest(ctx context.Context, req *adminv1.CreateGithubPullRequestRequest) (*adminv1.CreateGithubPullRequestResponse, error) { |
nothing calls this directly
no test coverage detected