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

Function fetchReleasesWithoutImmutableReleases

pkg/cmd/release/list/http.go:122–198  ·  view source on GitHub ↗

TODO: immutableReleaseFullSupport This is a temporary workaround until all supported GHES versions fully support immutable releases, which would be when GHES 3.18 goes EOL. At that point we can remove this function.

(httpClient *http.Client, repo ghrepo.Interface, limit int, excludeDrafts bool, excludePreReleases bool, order string)

Source from the content-addressed store, hash-verified

120// support immutable releases, which would be when GHES 3.18 goes EOL. At that
121// point we can remove this function.
122func fetchReleasesWithoutImmutableReleases(httpClient *http.Client, repo ghrepo.Interface, limit int, excludeDrafts bool, excludePreReleases bool, order string) ([]Release, error) {
123 type releaseOld struct {
124 Name string
125 TagName string
126 IsDraft bool
127 IsLatest bool
128 IsPrerelease bool
129 CreatedAt time.Time
130 PublishedAt time.Time
131 }
132
133 fromReleaseOld := func(old releaseOld) Release {
134 return Release{
135 Name: old.Name,
136 TagName: old.TagName,
137 IsDraft: old.IsDraft,
138 IsLatest: old.IsLatest,
139 IsPrerelease: old.IsPrerelease,
140 CreatedAt: old.CreatedAt,
141 PublishedAt: old.PublishedAt,
142 }
143 }
144
145 type responseData struct {
146 Repository struct {
147 Releases struct {
148 Nodes []releaseOld
149 PageInfo struct {
150 HasNextPage bool
151 EndCursor string
152 }
153 } `graphql:"releases(first: $perPage, orderBy: {field: CREATED_AT, direction: $direction}, after: $endCursor)"`
154 } `graphql:"repository(owner: $owner, name: $name)"`
155 }
156
157 perPage := min(limit, 100)
158
159 variables := map[string]any{
160 "owner": githubv4.String(repo.RepoOwner()),
161 "name": githubv4.String(repo.RepoName()),
162 "perPage": githubv4.Int(perPage),
163 "endCursor": (*githubv4.String)(nil),
164 "direction": githubv4.OrderDirection(strings.ToUpper(order)),
165 }
166
167 gql := api.NewClientFromHTTP(httpClient)
168
169 var releases []Release
170loop:
171 for {
172 var query responseData
173 err := gql.Query(repo.RepoHost(), "RepositoryReleaseList", &query, variables)
174 if err != nil {
175 return nil, err
176 }
177
178 for _, r := range query.Repository.Releases.Nodes {
179 if excludeDrafts && r.IsDraft {

Callers 1

fetchReleasesFunction · 0.85

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