add more issue / pr creation params #331

Merged
6543 merged 18 commits from noerw/tea:issue-create-opts into master 2021-03-08 11:48:04 +00:00
3 changed files with 15 additions and 18 deletions
Showing only changes of commit 623b82c3c8 - Show all commits

View File

@ -5,6 +5,7 @@
package issues
import (
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
@ -46,7 +47,10 @@ func runIssuesCreate(cmd *cli.Context) error {
ctx.Login,
ctx.Owner,
ctx.Repo,
ctx.String("title"),
ctx.String("body"),
gitea.CreateIssueOption{
Title: ctx.String("title"),
Body: ctx.String("body"),
// Labels: []int64{4157, 4730},
},
)
}

View File

@ -5,6 +5,7 @@
package interact
import (
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/task"
@ -38,6 +39,9 @@ func CreateIssue(login *config.Login, owner, repo string) error {
login,
owner,
repo,
title,
description)
gitea.CreateIssueOption{
Title: title,
Body: description,
},
)
}

View File

@ -13,25 +13,14 @@ import (
)
// CreateIssue creates an issue in the given repo and prints the result
func CreateIssue(login *config.Login, repoOwner, repoName, title, description string) error {
func CreateIssue(login *config.Login, repoOwner, repoName string, opts gitea.CreateIssueOption) error {
// title is required
if len(title) == 0 {
if len(opts.Title) == 0 {
return fmt.Errorf("Title is required")
}
issue, _, err := login.Client().CreateIssue(repoOwner, repoName, gitea.CreateIssueOption{
Title: title,
Body: description,
// TODO:
//Assignee string `json:"assignee"`
//Assignees []string `json:"assignees"`
//Deadline *time.Time `json:"due_date"`
//Milestone int64 `json:"milestone"`
//Labels []int64 `json:"labels"`
//Closed bool `json:"closed"`
})
issue, _, err := login.Client().CreateIssue(repoOwner, repoName, opts)
if err != nil {
return fmt.Errorf("could not create issue: %s", err)
}