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

Function generateReleaseNotes

pkg/cmd/release/create/http.go:75–108  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, tagName, target, previousTagName string)

Source from the content-addressed store, hash-verified

73}
74
75func generateReleaseNotes(httpClient *http.Client, repo ghrepo.Interface, tagName, target, previousTagName string) (*releaseNotes, error) {
76 params := map[string]any{
77 "tag_name": tagName,
78 }
79 if target != "" {
80 params["target_commitish"] = target
81 }
82 if previousTagName != "" {
83 params["previous_tag_name"] = previousTagName
84 }
85
86 bodyBytes, err := json.Marshal(params)
87 if err != nil {
88 return nil, err
89 }
90
91 path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "releases", "generate-notes")
92 if err != nil {
93 return nil, err
94 }
95
96 var rn releaseNotes
97 // TODO(api-client-rollout)
98 // This line of code is part of a mechanical roll out of the api client.
99 // As a follow up, consider whether the api client can be injected to this call site, rather than constructed
100 err = api.NewClientFromHTTP(httpClient).REST(repo.RepoHost(), http.MethodPost, path.String(), bytes.NewBuffer(bodyBytes), &rn)
101 if err != nil {
102 if httpErr, ok := errors.AsType[api.HTTPError](err); ok && httpErr.StatusCode == http.StatusNotFound {
103 return nil, notImplementedError
104 }
105 return nil, err
106 }
107 return &rn, nil
108}
109
110func publishedReleaseExists(httpClient *http.Client, repo ghrepo.Interface, tagName string) (bool, error) {
111 path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "releases", "tags", tagName)

Callers 3

createRunFunction · 0.85

Calls 7

JoinPathFunction · 0.92
NewClientFromHTTPFunction · 0.92
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65