MCPcopy
hub / github.com/cli/cli / apiClose

Function apiClose

pkg/cmd/issue/close/close.go:174–208  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, issue *api.Issue, reason string, duplicateIssueID string)

Source from the content-addressed store, hash-verified

172}
173
174func 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
210type CloseIssueInput struct {
211 IssueID string `json:"issueId"`

Callers 1

closeRunFunction · 0.85

Calls 5

PullRequestCloseFunction · 0.92
NewClientFromHTTPFunction · 0.92
MutateMethod · 0.65
RepoHostMethod · 0.65
IsPullRequestMethod · 0.45

Tested by

no test coverage detected