mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-16 02:16:24 -04:00
Add a --project/-p flag to `tea issues create` so newly created issues can be placed on a project board. The flag accepts either a project ID or title and adds the issue to the project default column. This uses the project APIs recently added to the Gitea SDK. Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
34 lines
806 B
Go
34 lines
806 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package task
|
|
|
|
import (
|
|
stdctx "context"
|
|
"fmt"
|
|
|
|
gitea "gitea.dev/sdk"
|
|
|
|
"gitea.dev/tea/modules/config"
|
|
"gitea.dev/tea/modules/print"
|
|
)
|
|
|
|
// CreateIssue creates an issue in the given repo and prints the result.
|
|
func CreateIssue(requestCtx stdctx.Context, rlogin *config.Login, repoOwner, repoName string, opts gitea.CreateIssueOption) (*gitea.Issue, error) {
|
|
// title is required
|
|
if len(opts.Title) == 0 {
|
|
return nil, fmt.Errorf("title is required")
|
|
}
|
|
|
|
issue, _, err := rlogin.Client().Issues.CreateIssue(requestCtx, repoOwner, repoName, opts)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not create issue: %s", err)
|
|
}
|
|
|
|
print.IssueDetails(issue, nil)
|
|
|
|
fmt.Println(issue.HTMLURL)
|
|
|
|
return issue, nil
|
|
}
|