MCPcopy Create free account
hub / github.com/cli/cli / listPullRequestTemplates

Function listPullRequestTemplates

pkg/cmd/pr/shared/templates.go:89–115  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

87}
88
89func 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
117type Template interface {
118 Name() string

Callers

nothing calls this directly

Calls 6

NewClientFromHTTPFunction · 0.92
StringMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected