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

Function generateReleaseNotes

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

Source from the content-addressed store, hash-verified

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