Normalize /slug team shorthand to org/slug and fix docs
This commit is contained in:
parent
a8655bcda9
commit
1cb776384e
3 changed files with 7 additions and 3 deletions
|
|
@ -764,8 +764,8 @@ func RemovePullRequestReviews(client *Client, repo ghrepo.Interface, prNumber in
|
|||
// RequestReviewsByLogin sets requested reviewers on a pull request using the GraphQL mutation.
|
||||
// This mutation replaces existing reviewers with the provided set unless union is true.
|
||||
// Only available on github.com, not GHES.
|
||||
// Bot logins should include the [bot] suffix (e.g., "copilot-pull-request-reviewer[bot]").
|
||||
// Team slugs should be in the format "org/team-slug".
|
||||
// Bot logins should be passed without the [bot] suffix; it is appended automatically.
|
||||
// Team slugs must be in the format "org/team-slug".
|
||||
// When union is false (replace mode), passing empty slices will remove all reviewers.
|
||||
func RequestReviewsByLogin(client *Client, repo ghrepo.Interface, prID string, userLogins, botLogins, teamSlugs []string, union bool) error {
|
||||
// In union mode (additive), nothing to do if all lists are empty.
|
||||
|
|
|
|||
|
|
@ -987,7 +987,7 @@ func Test_createRun(t *testing.T) {
|
|||
`, func(inputs map[string]interface{}) {
|
||||
assert.Equal(t, "NEWPULLID", inputs["pullRequestId"])
|
||||
assert.Equal(t, []interface{}{"hubot", "monalisa"}, inputs["userLogins"])
|
||||
assert.Equal(t, []interface{}{"/core", "/robots"}, inputs["teamSlugs"])
|
||||
assert.Equal(t, []interface{}{"OWNER/core", "OWNER/robots"}, inputs["teamSlugs"])
|
||||
assert.Equal(t, true, inputs["union"])
|
||||
}))
|
||||
},
|
||||
|
|
|
|||
|
|
@ -122,6 +122,10 @@ func AddMetadataToIssueParams(client *api.Client, baseRepo ghrepo.Interface, par
|
|||
var teamReviewers []string
|
||||
for _, r := range tb.Reviewers {
|
||||
if strings.ContainsRune(r, '/') {
|
||||
// Normalize /slug shorthand to org/slug using the repo owner
|
||||
if strings.HasPrefix(r, "/") {
|
||||
r = baseRepo.RepoOwner() + r
|
||||
}
|
||||
teamReviewers = append(teamReviewers, r)
|
||||
} else if r == api.CopilotReviewerLogin {
|
||||
botReviewers = append(botReviewers, r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue