gitea.tea/modules/task/issue_create.go
Lunny Xiao bc164f28f6 feat(issues): add --project flag to assign new issues to a board
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>
2026-08-21 10:22:53 -07:00

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
}