X Tutup
Skip to content

Commit 6b49e21

Browse files
committed
Improve issue status detection
1 parent 9436990 commit 6b49e21

File tree

6 files changed

+6
-8
lines changed

6 files changed

+6
-8
lines changed

api/queries_issue.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type Issue struct {
2626
Title string
2727
URL string
2828
State string
29-
Closed bool
3029
Body string
3130
CreatedAt time.Time
3231
UpdatedAt time.Time
@@ -237,7 +236,6 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
237236
id
238237
title
239238
state
240-
closed
241239
body
242240
author {
243241
login

pkg/cmd/issue/close/close.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func closeRun(opts *CloseOptions) error {
6565
return err
6666
}
6767

68-
if issue.Closed {
68+
if issue.State == "CLOSED" {
6969
fmt.Fprintf(opts.IO.ErrOut, "%s Issue #%d (%s) is already closed\n", cs.Yellow("!"), issue.Number, issue.Title)
7070
return nil
7171
}

pkg/cmd/issue/close/close_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func TestIssueClose_alreadyClosed(t *testing.T) {
9696
httpmock.StringResponse(`
9797
{ "data": { "repository": {
9898
"hasIssuesEnabled": true,
99-
"issue": { "number": 13, "title": "The title of the issue", "closed": true}
99+
"issue": { "number": 13, "title": "The title of the issue", "state": "CLOSED"}
100100
} } }`),
101101
)
102102

pkg/cmd/issue/reopen/reopen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func reopenRun(opts *ReopenOptions) error {
6565
return err
6666
}
6767

68-
if !issue.Closed {
68+
if issue.State == "OPEN" {
6969
fmt.Fprintf(opts.IO.ErrOut, "%s Issue #%d (%s) is already open\n", cs.Yellow("!"), issue.Number, issue.Title)
7070
return nil
7171
}

pkg/cmd/issue/reopen/reopen_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestIssueReopen(t *testing.T) {
6464
httpmock.StringResponse(`
6565
{ "data": { "repository": {
6666
"hasIssuesEnabled": true,
67-
"issue": { "id": "THE-ID", "number": 2, "closed": true, "title": "The title of the issue"}
67+
"issue": { "id": "THE-ID", "number": 2, "state": "CLOSED", "title": "The title of the issue"}
6868
} } }`),
6969
)
7070
http.Register(
@@ -96,7 +96,7 @@ func TestIssueReopen_alreadyOpen(t *testing.T) {
9696
httpmock.StringResponse(`
9797
{ "data": { "repository": {
9898
"hasIssuesEnabled": true,
99-
"issue": { "number": 2, "closed": false, "title": "The title of the issue"}
99+
"issue": { "number": 2, "state": "OPEN", "title": "The title of the issue"}
100100
} } }`),
101101
)
102102

pkg/cmd/issue/transfer/transfer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func Test_transferRunSuccessfulIssueTransfer(t *testing.T) {
118118
httpmock.StringResponse(`
119119
{ "data": { "repository": {
120120
"hasIssuesEnabled": true,
121-
"issue": { "id": "THE-ID", "number": 1234, "closed": true, "title": "The title of the issue"}
121+
"issue": { "id": "THE-ID", "number": 1234, "title": "The title of the issue"}
122122
} } }`))
123123

124124
http.Register(

0 commit comments

Comments
 (0)
X Tutup