mirror of
https://gitea.com/gitea/tea.git
synced 2024-11-24 11:31:36 +01:00
7b7c7f57be
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>
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package pulls
|
|
|
|
import (
|
|
"code.gitea.io/tea/cmd/flags"
|
|
"code.gitea.io/tea/modules/context"
|
|
"code.gitea.io/tea/modules/interact"
|
|
"code.gitea.io/tea/modules/task"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// CmdPullsCreate creates a pull request
|
|
var CmdPullsCreate = cli.Command{
|
|
Name: "create",
|
|
Aliases: []string{"c"},
|
|
Usage: "Create a pull-request",
|
|
Description: "Create a pull-request",
|
|
Action: runPullsCreate,
|
|
Flags: append([]cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "head",
|
|
Usage: "Set head branch (default is current one)",
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "base",
|
|
Aliases: []string{"b"},
|
|
Usage: "Set base branch (default is default branch)",
|
|
},
|
|
}, flags.IssuePREditFlags...),
|
|
}
|
|
|
|
func runPullsCreate(cmd *cli.Context) error {
|
|
ctx := context.InitCommand(cmd)
|
|
|
|
// no args -> interactive mode
|
|
if ctx.NumFlags() == 0 {
|
|
return interact.CreatePull(ctx)
|
|
}
|
|
|
|
// else use args to create PR
|
|
opts, err := flags.GetIssuePREditFlags(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return task.CreatePull(
|
|
ctx,
|
|
ctx.String("base"),
|
|
ctx.String("head"),
|
|
opts,
|
|
)
|
|
}
|