(httpClient *http.Client, repo ghrepo.Interface, issue *api.Issue, reason string, duplicateIssueID string)
| 172 | } |
| 173 | |
| 174 | func apiClose(httpClient *http.Client, repo ghrepo.Interface, issue *api.Issue, reason string, duplicateIssueID string) error { |
| 175 | if issue.IsPullRequest() { |
| 176 | return api.PullRequestClose(httpClient, repo, issue.ID) |
| 177 | } |
| 178 | |
| 179 | switch reason { |
| 180 | case "": |
| 181 | // If no reason is specified do not set it. |
| 182 | case "not planned": |
| 183 | reason = "NOT_PLANNED" |
| 184 | case "duplicate": |
| 185 | reason = "DUPLICATE" |
| 186 | default: |
| 187 | reason = "COMPLETED" |
| 188 | } |
| 189 | |
| 190 | var mutation struct { |
| 191 | CloseIssue struct { |
| 192 | Issue struct { |
| 193 | ID githubv4.ID |
| 194 | } |
| 195 | } `graphql:"closeIssue(input: $input)"` |
| 196 | } |
| 197 | |
| 198 | variables := map[string]interface{}{ |
| 199 | "input": CloseIssueInput{ |
| 200 | IssueID: issue.ID, |
| 201 | StateReason: reason, |
| 202 | DuplicateIssueID: duplicateIssueID, |
| 203 | }, |
| 204 | } |
| 205 | |
| 206 | gql := api.NewClientFromHTTP(httpClient) |
| 207 | return gql.Mutate(repo.RepoHost(), "IssueClose", &mutation, variables) |
| 208 | } |
| 209 | |
| 210 | type CloseIssueInput struct { |
| 211 | IssueID string `json:"issueId"` |
no test coverage detected