mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 09:58:29 +02:00
Add more issue / pr creation params (#331)
adds assignees, labels, deadline, milestone params - [x] add flags to `tea issue create` (this is BREAKING, `-b` moved to `-d` for consistency with pr create) - [x] add interactive mode to `tea issue create` - [x] add flags to `tea pr create` - [x] add interactive mode to `tea pr create` fixes #171, fixes #303 Co-authored-by: Norwin Roosen <git@nroo.de> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/331 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:
@ -5,6 +5,7 @@
|
||||
package interact
|
||||
|
||||
import (
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/git"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
@ -14,7 +15,7 @@ import (
|
||||
|
||||
// CreatePull interactively creates a PR
|
||||
func CreatePull(login *config.Login, owner, repo string) error {
|
||||
var base, head, title, description string
|
||||
var base, head string
|
||||
|
||||
// owner, repo
|
||||
owner, repo, err := promptRepoSlug(owner, repo)
|
||||
@ -23,17 +24,14 @@ func CreatePull(login *config.Login, owner, repo string) error {
|
||||
}
|
||||
|
||||
// base
|
||||
baseBranch, err := task.GetDefaultPRBase(login, owner, repo)
|
||||
base, err = task.GetDefaultPRBase(login, owner, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
promptI := &survey.Input{Message: "Target branch [" + baseBranch + "]:"}
|
||||
promptI := &survey.Input{Message: "Target branch:", Default: base}
|
||||
if err := survey.AskOne(promptI, &base); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(base) == 0 {
|
||||
base = baseBranch
|
||||
}
|
||||
|
||||
// head
|
||||
localRepo, err := git.RepoForWorkdir()
|
||||
@ -45,38 +43,19 @@ func CreatePull(login *config.Login, owner, repo string) error {
|
||||
if err == nil {
|
||||
promptOpts = nil
|
||||
}
|
||||
var headOwnerInput, headBranchInput string
|
||||
promptI = &survey.Input{Message: "Source repo owner [" + headOwner + "]:"}
|
||||
if err := survey.AskOne(promptI, &headOwnerInput); err != nil {
|
||||
promptI = &survey.Input{Message: "Source repo owner:", Default: headOwner}
|
||||
if err := survey.AskOne(promptI, &headOwner); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(headOwnerInput) != 0 {
|
||||
headOwner = headOwnerInput
|
||||
}
|
||||
promptI = &survey.Input{Message: "Source branch [" + headBranch + "]:"}
|
||||
if err := survey.AskOne(promptI, &headBranchInput, promptOpts); err != nil {
|
||||
promptI = &survey.Input{Message: "Source branch:", Default: headBranch}
|
||||
if err := survey.AskOne(promptI, &headBranch, promptOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(headBranchInput) != 0 {
|
||||
headBranch = headBranchInput
|
||||
}
|
||||
|
||||
head = task.GetHeadSpec(headOwner, headBranch, owner)
|
||||
|
||||
// title
|
||||
title = task.GetDefaultPRTitle(head)
|
||||
promptOpts = survey.WithValidator(survey.Required)
|
||||
if len(title) != 0 {
|
||||
promptOpts = nil
|
||||
}
|
||||
promptI = &survey.Input{Message: "PR title [" + title + "]:"}
|
||||
if err := survey.AskOne(promptI, &title, promptOpts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// description
|
||||
promptM := &survey.Multiline{Message: "PR description:"}
|
||||
if err := survey.AskOne(promptM, &description); err != nil {
|
||||
opts := gitea.CreateIssueOption{Title: task.GetDefaultPRTitle(head)}
|
||||
if err = promptIssueProperties(login, owner, repo, &opts); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -86,6 +65,5 @@ func CreatePull(login *config.Login, owner, repo string) error {
|
||||
repo,
|
||||
base,
|
||||
head,
|
||||
title,
|
||||
description)
|
||||
&opts)
|
||||
}
|
||||
|
Reference in New Issue
Block a user