X Tutup
Skip to content

Commit 25d79c4

Browse files
authored
Merge pull request cli#3525 from cristiand391/improve-issue-status-detection
Improve issue status detection
2 parents 011e455 + 796d2e2 commit 25d79c4

File tree

6 files changed

+6
-7
lines changed

6 files changed

+6
-7
lines changed

api/queries_issue.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ func IssueByNumber(client *Client, repo ghrepo.Interface, number int) (*Issue, e
237237
id
238238
title
239239
state
240-
closed
241240
body
242241
author {
243242
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