| 87 | } |
| 88 | |
| 89 | func listPullRequestTemplates(httpClient *http.Client, repo ghrepo.Interface) ([]Template, error) { |
| 90 | var query struct { |
| 91 | Repository struct { |
| 92 | PullRequestTemplates []pullRequestTemplate |
| 93 | } `graphql:"repository(owner: $owner, name: $name)"` |
| 94 | } |
| 95 | |
| 96 | variables := map[string]any{ |
| 97 | "owner": githubv4.String(repo.RepoOwner()), |
| 98 | "name": githubv4.String(repo.RepoName()), |
| 99 | } |
| 100 | |
| 101 | gql := api.NewClientFromHTTP(httpClient) |
| 102 | |
| 103 | err := gql.Query(repo.RepoHost(), "PullRequestTemplates", &query, variables) |
| 104 | if err != nil { |
| 105 | return nil, err |
| 106 | } |
| 107 | |
| 108 | ts := query.Repository.PullRequestTemplates |
| 109 | templates := make([]Template, len(ts)) |
| 110 | for i := range templates { |
| 111 | templates[i] = &ts[i] |
| 112 | } |
| 113 | |
| 114 | return templates, nil |
| 115 | } |
| 116 | |
| 117 | type Template interface { |
| 118 | Name() string |