-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Show the state (open, closed, merged) in issue view and pr view #667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me. Thanks for the hard work @doi-t! ✨
| for name, tc := range tests { | ||
| t.Run(name, func(t *testing.T) { | ||
| got := issueStateTitleWithColor(tc.state) | ||
| diff := cmp.Diff(tc.want, got) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL go-cmp! 🏆
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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