Show the state (open, closed, merged) in issue view and pr view#667
Show the state (open, closed, merged) in issue view and pr view#667mislav merged 27 commits intocli:masterfrom
Conversation
utils/utils.go
Outdated
| } | ||
|
|
||
| // ColorFuncForState returns a color function for a PR/Issue state | ||
| func ColorFuncForState(state string) func(string) string { |
There was a problem hiding this comment.
Since colorFuncForState was referenced from both command/issue.go and command/pr.go, I moved it to utils.go.
There was a problem hiding this comment.
Nit: could you move this back to the command package, since it's only needed there? We're trying to slim down the utils package until we can remove it.
I can live in either issue.go or pr.go; it doesn't matter.
7509efa to
0ba0a07
Compare
|
@mislav @vilmibm |
Of course! That sounds reasonable. Please feel free to make a nested PR 👍 |
| for name, tc := range tests { | ||
| t.Run(name, func(t *testing.T) { | ||
| got := issueStateTitleWithColor(tc.state) | ||
| diff := cmp.Diff(tc.want, got) |
| http := initFakeHTTP() | ||
| http.StubRepoResponse("OWNER", "REPO") | ||
| for name, tc := range tests { | ||
| t.Run(name, func(t *testing.T) { |
There was a problem hiding this comment.
Massive props for table-driven test 🥇
utils/utils.go
Outdated
| } | ||
|
|
||
| // ColorFuncForState returns a color function for a PR/Issue state | ||
| func ColorFuncForState(state string) func(string) string { |
There was a problem hiding this comment.
Nit: could you move this back to the command package, since it's only needed there? We're trying to slim down the utils package until we can remove it.
I can live in either issue.go or pr.go; it doesn't matter.
mislav
left a comment
There was a problem hiding this comment.
This looks excellent to me. Thank you for the hard work 🌟



Closes #652
Mostly tests for each state. Changes for the core logics are a few lines in
command/issue.go,command/pr.goand GraphQL queries.Since colors matter, I tried to test PR/Issue states with ansi escape sequence to compare colors along with its string but couldn't figure out an efficient way to do... I might be missing something for it.
Test cases for
gh [pr|issue] view --previewI use
•(Bullet:U+2022) as a separator. It is a bit ugly in below captures but I think it is my terminal font problem. 💦Open issue

Closed issue

Open PR
Draft PR
OpentoDraftlike below if it is more appropriateClosed PR
Merged PR