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