From 0970b945529b97ae1e504261202761a7b203e0cd Mon Sep 17 00:00:00 2001 From: Norwin Date: Sat, 26 Mar 2022 15:32:53 +0800 Subject: [PATCH] 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 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 Co-authored-by: Norwin Co-committed-by: Norwin --- cmd/pulls/checkout.go | 5 ++++- cmd/repos/fork.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/pulls/checkout.go b/cmd/pulls/checkout.go index 7dade3d..ba28bca 100644 --- a/cmd/pulls/checkout.go +++ b/cmd/pulls/checkout.go @@ -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") } diff --git a/cmd/repos/fork.go b/cmd/repos/fork.go index 1811fce..53052bd 100644 --- a/cmd/repos/fork.go +++ b/cmd/repos/fork.go @@ -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{}