(client *http.Client, hostname, owner string)
| 273 | } |
| 274 | |
| 275 | func listTemplateRepositories(client *http.Client, hostname, owner string) ([]api.Repository, error) { |
| 276 | ownerConnection := "repositoryOwner(login: $owner)" |
| 277 | |
| 278 | variables := map[string]interface{}{ |
| 279 | "perPage": githubv4.Int(100), |
| 280 | "owner": githubv4.String(owner), |
| 281 | } |
| 282 | inputs := []string{"$perPage:Int!", "$endCursor:String", "$owner:String!"} |
| 283 | |
| 284 | type result struct { |
| 285 | RepositoryOwner struct { |
| 286 | Login string |
| 287 | Repositories struct { |
| 288 | Nodes []api.Repository |
| 289 | TotalCount int |
| 290 | PageInfo struct { |
| 291 | HasNextPage bool |
| 292 | EndCursor string |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | query := fmt.Sprintf(`query RepositoryList(%s) { |
| 299 | %s { |
| 300 | login |
| 301 | repositories(first: $perPage, after: $endCursor, ownerAffiliations: OWNER, orderBy: { field: PUSHED_AT, direction: DESC }) { |
| 302 | nodes{ |
| 303 | id |
| 304 | name |
| 305 | isTemplate |
| 306 | defaultBranchRef { |
| 307 | name |
| 308 | } |
| 309 | } |
| 310 | totalCount |
| 311 | pageInfo{hasNextPage,endCursor} |
| 312 | } |
| 313 | } |
| 314 | }`, strings.Join(inputs, ","), ownerConnection) |
| 315 | |
| 316 | apiClient := api.NewClientFromHTTP(client) |
| 317 | var templateRepositories []api.Repository |
| 318 | for { |
| 319 | var res result |
| 320 | err := apiClient.GraphQL(hostname, query, variables, &res) |
| 321 | if err != nil { |
| 322 | return nil, err |
| 323 | } |
| 324 | |
| 325 | owner := res.RepositoryOwner |
| 326 | |
| 327 | for _, repo := range owner.Repositories.Nodes { |
| 328 | if repo.IsTemplate { |
| 329 | templateRepositories = append(templateRepositories, repo) |
| 330 | } |
| 331 | } |
| 332 |
no test coverage detected