FIX: conditionally fetching team reviewers
Updated the logic for fetching team reviewers in PR edit and create flows. In `pr edit`, team reviewers are always fetched for consistency with existing behavior, with a note to potentially align with `pr create` logic in the future. In `pr create`, team reviewers are now only fetched if a reviewer contains a slash, aligning with behavior before the regression.
This commit is contained in:
parent
449920b40f
commit
df317d4a05
3 changed files with 15 additions and 10 deletions
|
|
@ -1314,14 +1314,6 @@ func Test_createRun(t *testing.T) {
|
|||
"pageInfo": { "hasNextPage": false }
|
||||
} } } }
|
||||
`))
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`query OrganizationTeamList\b`),
|
||||
httpmock.StringResponse(`
|
||||
{ "data": { "organization": { "teams": {
|
||||
"nodes": [],
|
||||
"pageInfo": { "hasNextPage": false }
|
||||
} } } }
|
||||
`))
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`mutation PullRequestCreateRequestReviews\b`),
|
||||
httpmock.GraphQLMutation(`
|
||||
|
|
|
|||
|
|
@ -429,7 +429,16 @@ func FieldsToEditSurvey(p EditPrompter, editable *Editable) error {
|
|||
|
||||
func FetchOptions(client *api.Client, repo ghrepo.Interface, editable *Editable) error {
|
||||
input := api.RepoMetadataInput{
|
||||
Reviewers: editable.Reviewers.Edited,
|
||||
Reviewers: editable.Reviewers.Edited,
|
||||
// TeamReviewers is always true if Reviewers is true because
|
||||
// this is the existing `pr edit` behavior. This means
|
||||
// always fetch teams.
|
||||
// TODO: evaluate whether this can follow the same logic as
|
||||
// `pr create` to conditionally fetch teams if a reviewer contains
|
||||
// a slash.
|
||||
// See https://github.com/cli/cli/blob/449920b40fc8a5015d1578ca10a301aa385a1914/pkg/cmd/pr/shared/params.go#L67-L71
|
||||
// See https://github.com/cli/cli/issues/11360
|
||||
TeamReviewers: editable.Reviewers.Edited,
|
||||
Assignees: editable.Assignees.Edited,
|
||||
ActorAssignees: editable.Assignees.ActorAssignees,
|
||||
Labels: editable.Labels.Edited,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package shared
|
|||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
|
|
@ -63,7 +64,10 @@ func AddMetadataToIssueParams(client *api.Client, baseRepo ghrepo.Interface, par
|
|||
// Retrieve minimal information needed to resolve metadata if this was not previously cached from additional metadata survey.
|
||||
if tb.MetadataResult == nil {
|
||||
input := api.RepoMetadataInput{
|
||||
Reviewers: len(tb.Reviewers) > 0,
|
||||
Reviewers: len(tb.Reviewers) > 0,
|
||||
TeamReviewers: len(tb.Reviewers) > 0 && slices.ContainsFunc(tb.Reviewers, func(r string) bool {
|
||||
return strings.ContainsRune(r, '/')
|
||||
}),
|
||||
Assignees: len(tb.Assignees) > 0,
|
||||
ActorAssignees: tb.ActorAssignees,
|
||||
Labels: len(tb.Labels) > 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue