-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Add support for issue state reason #6245
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
| @@ -1,189 +1,281 @@ | |||
| package close | |||
|
|
|||
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.
Migrated these tests from old style to new style hence the large number of line changes.
mislav
left a comment
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.
Looks great!
pkg/cmd/issue/view/view.go
Outdated
| if features.StateReason { | ||
| lookupFields.Add("stateReason") |
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.
Do you think it would it be simpler to push this logic into shared.findIssueOrPR?
Example: if findIssueOrPR was invoked with stateReason among fields, use featuredetector to determine whether it's supported, and scrub it out if not. Prior art:
cli/pkg/cmd/pr/shared/finder.go
Lines 142 to 151 in e2e8d69
| if fields.Contains("isInMergeQueue") || fields.Contains("isMergeQueueEnabled") { | |
| cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24) | |
| detector := fd.NewDetector(cachedClient, f.repo.RepoHost()) | |
| prFeatures, err := detector.PullRequestFeatures() | |
| if err != nil { | |
| return nil, nil, err | |
| } | |
| if !prFeatures.MergeQueue { | |
| fields.Remove("isInMergeQueue") | |
| fields.Remove("isMergeQueueEnabled") |
This way, all callers of findIssueOrPR across all commands would not have to worry about GHES not supporting certain fields.
The only gotcha would be that a fd.Detector would have to be passed down as an injectable, though 🤔 Feel free to disregard if that's too much hassle.
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.
I like this idea. I went ahead and implemented it. Luckily (or unluckily) none of our issue tests target GHES so the feature detection here is a no-op and doesn't need to be injected for testing purposes.
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.
Future tests that target GHES could also just mock out the request instead of having to inject the detector.
27149a6 to
b44c19c
Compare
This PR adds support for issue state reason to various commands:
issue listset color for closed issues according to state reasonissue viewset color for closed issues according to state reasonsearch issuesset color for closed issues according to state reasonissue closeadd--reasonflag to allow closing of issues with a reason.This PR does not add support of searching by issue state reason to
issue listorsearch issues. Both of those commands support custom search queries that can be used to search by issue state reason according to the docs. We can revisit adding in dedicated flags for this later, but I felt as support for issue state reason was only introduced in GHES 3.6 that adding in flags that did not work on all supported GHES versions would be confusing for users of GHES older than 3.6.cc/ @azenMatt
cc/ https://github.com/github/cli/issues/114