Fix context requirements of subcommands (#474)

`tea repo fork` and `tea pr checkout` were missing the requirement of a remote repo.

fixes https://gitea.com/gitea/tea/issues/444

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/474
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin 2022-03-26 15:32:53 +08:00 committed by Lunny Xiao
parent dda94a5dea
commit 0970b94552
2 changed files with 5 additions and 1 deletions

View File

@ -35,7 +35,10 @@ var CmdPullsCheckout = cli.Command{
func runPullsCheckout(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{LocalRepo: true})
ctx.Ensure(context.CtxRequirement{
LocalRepo: true,
RemoteRepo: true,
})
if ctx.Args().Len() != 1 {
return fmt.Errorf("Must specify a PR index")
}

View File

@ -33,6 +33,7 @@ var CmdRepoFork = cli.Command{
func runRepoFork(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
opts := gitea.CreateForkOption{}