add more issue / pr creation params #331
|
@ -5,6 +5,7 @@
|
|||
package pulls
|
||||
|
||||
import (
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/cmd/flags"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
"code.gitea.io/tea/modules/interact"
|
||||
|
@ -59,7 +60,9 @@ func runPullsCreate(cmd *cli.Context) error {
|
|||
ctx.Repo,
|
||||
ctx.String("base"),
|
||||
ctx.String("head"),
|
||||
ctx.String("title"),
|
||||
ctx.String("description"),
|
||||
&gitea.CreateIssueOption{
|
||||
Title: ctx.String("title"),
|
||||
Body: ctx.String("description"),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
@ -53,20 +54,8 @@ func CreatePull(login *config.Login, owner, repo string) error {
|
|||
|
||||
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:", Default: 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
|
||||
}
|
||||
|
||||
|
@ -76,6 +65,5 @@ func CreatePull(login *config.Login, owner, repo string) error {
|
|||
repo,
|
||||
base,
|
||||
head,
|
||||
title,
|
||||
description)
|
||||
&opts)
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ import (
|
|||
)
|
||||
|
||||
// CreatePull creates a PR in the given repo and prints the result
|
||||
func CreatePull(login *config.Login, repoOwner, repoName, base, head, title, description string) error {
|
||||
|
||||
func CreatePull(login *config.Login, repoOwner, repoName, base, head string, opts *gitea.CreateIssueOption) error {
|
||||
// open local git repo
|
||||
localRepo, err := local_git.RepoForWorkdir()
|
||||
if err != nil {
|
||||
|
@ -57,19 +56,23 @@ func CreatePull(login *config.Login, repoOwner, repoName, base, head, title, des
|
|||
}
|
||||
|
||||
// default is head branch name
|
||||
if len(title) == 0 {
|
||||
title = GetDefaultPRTitle(head)
|
||||
if len(opts.Title) == 0 {
|
||||
opts.Title = GetDefaultPRTitle(head)
|
||||
}
|
||||
// title is required
|
||||
if len(title) == 0 {
|
||||
if len(opts.Title) == 0 {
|
||||
return fmt.Errorf("Title is required")
|
||||
}
|
||||
|
||||
pr, _, err := login.Client().CreatePullRequest(repoOwner, repoName, gitea.CreatePullRequestOption{
|
||||
Head: head,
|
||||
Base: base,
|
||||
Title: title,
|
||||
Body: description,
|
||||
Head: head,
|
||||
Base: base,
|
||||
Title: opts.Title,
|
||||
Body: opts.Body,
|
||||
Assignees: opts.Assignees,
|
||||
Labels: opts.Labels,
|
||||
Milestone: opts.Milestone,
|
||||
Deadline: opts.Deadline,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user