mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-10 07:26:33 -04:00
Closes #571. Adds three pieces: - 'tea pulls create --reviewer <user>[,<user>...] [--team-reviewer <team>...]' to request reviews at PR-creation time (passes through to CreatePullRequestOption.Reviewers / TeamReviewers). - 'tea pulls request-review <idx> [<idx>...]' / 'tea pulls cancel-review ...' subcommands wrapping POST/DELETE /requested_reviewers, with both --reviewer and --team-reviewer CSV flags. - 'tea pulls reviewers' listing subcommand (GET /reviewers) so users can discover who can be requested before they invoke the above. The WIP/draft toggle was deliberately deferred: upstream main already exposes 'tea pulls create --draft' and 'tea pulls edit --draft/--ready' (PR #1008), so this patch stays focused on reviewer support only. Verification: make fmt fmt-check vet lint test docs docs-check build ./tea pulls create --help / request-review --help / cancel-review --help / reviewers --help Signed-off-by: Ross Golder <ross@golder.org>
40 lines
1 KiB
Go
40 lines
1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package pulls
|
|
|
|
import (
|
|
stdctx "context"
|
|
|
|
"github.com/urfave/cli/v3"
|
|
|
|
"gitea.dev/tea/cmd/flags"
|
|
"gitea.dev/tea/modules/context"
|
|
"gitea.dev/tea/modules/print"
|
|
)
|
|
|
|
// CmdPullsReviewers lists users that can be requested to review pull requests
|
|
var CmdPullsReviewers = cli.Command{
|
|
Name: "reviewers",
|
|
Aliases: []string{"rs"},
|
|
Usage: "List users that can be requested to review pull requests in this repo",
|
|
Description: `Calls GET /repos/{owner}/{repo}/reviewers.`,
|
|
Action: runReviewersList,
|
|
Flags: flags.AllDefaultFlags,
|
|
}
|
|
|
|
func runReviewersList(requestCtx stdctx.Context, cmd *cli.Command) error {
|
|
ctx, err := context.InitCommand(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := ctx.Ensure(context.CtxRequirement{RemoteRepo: true}); err != nil {
|
|
return err
|
|
}
|
|
users, _, err := ctx.Login.Client().Repositories.GetReviewers(requestCtx, ctx.Owner, ctx.Repo)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return print.ReviewersList(users, ctx.Output)
|
|
}
|