Issue close works
Co-Authored-By: Nate Smith <vilmibm@neongrid.space>
This commit is contained in:
parent
ad48d8b3c3
commit
a2f0cc6de7
1 changed files with 16 additions and 7 deletions
|
|
@ -22,6 +22,7 @@ type IssuesAndTotalCount struct {
|
|||
|
||||
// Ref. https://developer.github.com/v4/object/issue/
|
||||
type Issue struct {
|
||||
ID string
|
||||
Number int
|
||||
Title string
|
||||
URL string
|
||||
|
|
@ -298,6 +299,7 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
|
|||
repository(owner: $owner, name: $repo) {
|
||||
hasIssuesEnabled
|
||||
issue(number: $issue_number) {
|
||||
id
|
||||
title
|
||||
state
|
||||
body
|
||||
|
|
@ -360,22 +362,29 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
|
|||
}
|
||||
|
||||
func IssueClose(client *Client, repo ghrepo.Interface, issueNumber int) error {
|
||||
issue, err := IssueByNumber(client, repo, issueNumber)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Faile to find issue #%d: %w", issueNumber, err)
|
||||
}
|
||||
|
||||
var mutation struct {
|
||||
closeIssue struct {
|
||||
CloseIssue struct {
|
||||
Issue struct {
|
||||
ID githubv4.ID
|
||||
}
|
||||
} `graphql:"closeIssue(input: $input)"`
|
||||
}
|
||||
|
||||
input := githubv4.CloseIssueInput{
|
||||
IssueID: issueNumber,
|
||||
IssueID: issue.ID,
|
||||
}
|
||||
|
||||
v4 := githubv4.NewClient(client.http)
|
||||
err := v4.Mutate(context.Background(), &mutation, input, nil)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
err = v4.Mutate(context.Background(), &mutation, input, nil)
|
||||
|
||||
fmt.Printf("%v\n", mutation)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue