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