Repository: seachicken/gh-poi (go)

Issue:
For draft PRs, the color of the PR number should be gray
**Description**
Now, in the result output, `#1` is green.

```
Not deleted branches
  main
* issue1
    └─ #1  https://example.com seachicken
```

In the GitHub UI, it will be gray, so we want to unify it to gray.

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->


Pull request:
Gray out the issue number in the draft PR
Resolves #23 

Patch:
diff --git a/conn/command.go b/conn/command.go
index 0c81567..326841b 100644
--- a/conn/command.go
+++ b/conn/command.go
@@ -81,6 +81,7 @@ func (conn *Connection) GetPullRequests(
           number
           url
           state
+          isDraft
           headRefName
           commits(last: 10) {
             nodes {
diff --git a/conn/fixtures/gh/pr_issue1Closed.json b/conn/fixtures/gh/pr_issue1Closed.json
index f004db6..9908a7f 100644
--- a/conn/fixtures/gh/pr_issue1Closed.json
+++ b/conn/fixtures/gh/pr_issue1Closed.json
@@ -8,6 +8,7 @@
             "number": 1,
             "url": "https://github.com/owner/repo/pull/1",
             "state": "CLOSED",
+            "isDraft": false,
             "headRefName": "issue1",
             "commits": {
               "nodes": [
diff --git a/conn/fixtures/gh/pr_issue1Merged.json b/conn/fixtures/gh/pr_issue1Merged.json
index 8f79922..a366e08 100644
--- a/conn/fixtures/gh/pr_issue1Merged.json
+++ b/conn/fixtures/gh/pr_issue1Merged.json
@@ -8,6 +8,7 @@
             "number": 1,
             "url": "https://github.com/owner/repo/pull/1",
             "state": "MERGED",
+            "isDraft": false,
             "headRefName": "issue1",
             "commits": {
               "nodes": [
diff --git a/conn/fixtures/gh/pr_issue1Merged_issue1Closed.json b/conn/fixtures/gh/pr_issue1Merged_issue1Closed.json
index f01910e..bad324b 100644
--- a/conn/fixtures/gh/pr_issue1Merged_issue1Closed.json
+++ b/conn/fixtures/gh/pr_issue1Merged_issue1Closed.json
@@ -8,6 +8,7 @@
             "number": 1,
             "url": "https://github.com/owner/repo/pull/1",
             "state": "CLOSED",
+            "isDraft": false,
             "headRefName": "issue1",
             "commits": {
               "nodes": [
@@ -28,6 +29,7 @@
             "number": 2,
             "url": "https://github.com/owner/repo/pull/2",
             "state": "MERGED",
+            "isDraft": false,
             "headRefName": "issue1",
             "commits": {
               "nodes": [
diff --git a/conn/fixtures/gh/pr_issue1UpMerged.json b/conn/fixtures/gh/pr_issue1UpMerged.json
index 1ac6af8..30e1230 100644
--- a/conn/fixtures/gh/pr_issue1UpMerged.json
+++ b/conn/fixtures/gh/pr_issue1UpMerged.json
@@ -8,6 +8,7 @@
             "number": 1,
             "url": "https://github.com/parent-owner/repo/pull/1",
             "state": "MERGED",
+            "isDraft": false,
             "headRefName": "issue1",
             "commits": {
               "nodes": [
diff --git a/conn/fixtures/gh/pr_mainMerged.json b/conn/fixtures/gh/pr_mainMerged.json
index 5d1b18a..4567be0 100644
--- a/conn/fixtures/gh/pr_mainMerged.json
+++ b/conn/fixtures/gh/pr_mainMerged.json
@@ -8,6 +8,7 @@
             "number": 1,
             "url": "https://github.com/owner/repo/pull/1",
             "state": "MERGED",
+            "isDraft": false,
             "headRefName": "main",
             "commits": {
               "nodes": [
diff --git a/main.go b/main.go
index 2d3edb0..e89d322 100644
--- a/main.go
+++ b/main.go
@@ -111,7 +111,7 @@ func printBranches(branches []Branch) {
 
 		for i, pr := range branch.PullRequests {
 			number := fmt.Sprintf("#%v", pr.Number)
-			issueNoColor := getIssueNoColor(pr.State)
+			issueNoColor := getIssueNoColor(pr.State, pr.IsDraft)
 			var line string
 			if i == len(branch.PullRequests)-1 {
 				line = "└─"
@@ -129,7 +129,11 @@ func printBranches(branches []Branch) {
 	}
 }
 
-func getIssueNoColor(state PullRequestState) color.Attribute {
+func getIssueNoColor(state PullRequestState, isDraft bool) color.Attribute {
+	if isDraft {
+		return color.FgHiBlack
+	}
+
 	switch state {
 	case Open:
 		return color.FgGreen
diff --git a/poi.go b/poi.go
index 79066c0..8c3ce02 100644
--- a/poi.go
+++ b/poi.go
@@ -45,6 +45,7 @@ type (
 	PullRequest struct {
 		Name    string
 		State   PullRequestState
+		IsDraft bool
 		Number  int
 		Commits []string
 		Url     string
@@ -421,6 +422,7 @@ func toPullRequests(jsonResp string) ([]PullRequest, error) {
 						HeadRefOid  string
 						Url         string
 						State       string
+						IsDraft     bool
 						Commits     struct {
 							Nodes []struct {
 								Commit struct {
@@ -457,6 +459,7 @@ func toPullRequests(jsonResp string) ([]PullRequest, error) {
 		results = append(results, PullRequest{
 			edge.Node.HeadRefName,
 			state,
+			edge.Node.IsDraft,
 			edge.Node.Number,
 			commits,
 			edge.Node.Url,


Test patch:
diff --git a/poi_test.go b/poi_test.go
index 8b33247..cb402aa 100644
--- a/poi_test.go
+++ b/poi_test.go
@@ -38,7 +38,7 @@ func Test_ShouldBeDeletableWhenBranchesAssociatedWithMergedPR(t *testing.T) {
 			},
 			[]PullRequest{
 				{
-					"issue1", Merged, 1,
+					"issue1", Merged, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -85,7 +85,7 @@ func Test_ShouldBeDeletableWhenBranchesAssociatedWithUpstreamMergedPR(t *testing
 			},
 			[]PullRequest{
 				{
-					"issue1", Merged, 1,
+					"issue1", Merged, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -133,7 +133,7 @@ func Test_ShouldBeDeletableWhenBranchIsCheckedOutWithTheCheckIsFalse(t *testing.
 			},
 			[]PullRequest{
 				{
-					"issue1", Merged, 1,
+					"issue1", Merged, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -181,7 +181,7 @@ func Test_ShouldBeDeletableWhenBranchIsCheckedOutWithTheCheckIsTrue(t *testing.T
 			},
 			[]PullRequest{
 				{
-					"issue1", Merged, 1,
+					"issue1", Merged, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -229,7 +229,7 @@ func Test_ShouldBeDeletableWhenBranchIsCheckedOutWithoutADefaultBranch(t *testin
 			},
 			[]PullRequest{
 				{
-					"issue1", Merged, 1,
+					"issue1", Merged, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -277,7 +277,7 @@ func Test_ShouldNotDeletableWhenBranchHasUncommittedChanges(t *testing.T) {
 			},
 			[]PullRequest{
 				{
-					"issue1", Merged, 1,
+					"issue1", Merged, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -324,7 +324,7 @@ func Test_ShouldNotDeletableWhenBranchesAssociatedWithClosedPR(t *testing.T) {
 			},
 			[]PullRequest{
 				{
-					"issue1", Closed, 1,
+					"issue1", Closed, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -371,14 +371,14 @@ func Test_ShouldBeDeletableWhenBranchesAssociatedWithMergedAndClosedPRs(t *testi
 			},
 			[]PullRequest{
 				{
-					"issue1", Closed, 1,
+					"issue1", Closed, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
 					"https://github.com/owner/repo/pull/1", "owner",
 				},
 				{
-					"issue1", Merged, 2,
+					"issue1", Merged, false, 2,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -428,7 +428,7 @@ func Test_ShouldNotDeletableWhenBranchesAssociatedWithNotFullyMergedPR(t *testin
 			},
 			[]PullRequest{
 				{
-					"issue1", Merged, 1,
+					"issue1", Merged, false, 1,
 					[]string{
 						"a97e9630426df5d34ca9ee77ae1159bdfd5ff8f0",
 					},
@@ -481,7 +481,7 @@ func Test_ShouldNotDeletableWhenDefaultBranchAssociatedWithMergedPR(t *testing.T
 			[]string{},
 			[]PullRequest{
 				{
-					"main", Merged, 1,
+					"main", Merged, false, 1,
 					[]string{
 						"6ebe3d30d23531af56bd23b5a098d3ccae2a534a",
 					},