tea pr create: make local repo optional (#393)

this is a partial fix to #378, making the command available outside of a local repo.

new behaviour:
- when run interactively without local repo context, the head repo prompt is not pre-populated
- when run with flags without local repo context, it will complain unless `--head` is specified

refactor:
- pass TeaContext down to task.CreatePull

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/393
Reviewed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin
2021-09-22 23:48:21 +08:00
committed by 6543
parent 6e728cf812
commit 7b7c7f57be
3 changed files with 27 additions and 37 deletions

View File

@ -35,11 +35,10 @@ var CmdPullsCreate = cli.Command{
func runPullsCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{LocalRepo: true})
// no args -> interactive mode
if ctx.NumFlags() == 0 {
return interact.CreatePull(ctx.Login, ctx.Owner, ctx.Repo)
return interact.CreatePull(ctx)
}
// else use args to create PR
@ -49,9 +48,7 @@ func runPullsCreate(cmd *cli.Context) error {
}
return task.CreatePull(
ctx.Login,
ctx.Owner,
ctx.Repo,
ctx,
ctx.String("base"),
ctx.String("head"),
opts,