mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-05 18:58:43 +02:00
8e0666ab85
Reviewed-on: https://gitea.com/gitea/tea/pulls/1003 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-committed-by: techknowlogick <techknowlogick@gitea.com>
33 lines
710 B
Go
33 lines
710 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package task
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.gitea.io/sdk/gitea"
|
|
|
|
"gitea.dev/tea/modules/config"
|
|
"gitea.dev/tea/modules/print"
|
|
)
|
|
|
|
// CreateIssue creates an issue in the given repo and prints the result
|
|
func CreateIssue(login *config.Login, repoOwner, repoName string, opts gitea.CreateIssueOption) error {
|
|
// title is required
|
|
if len(opts.Title) == 0 {
|
|
return fmt.Errorf("title is required")
|
|
}
|
|
|
|
issue, _, err := login.Client().CreateIssue(repoOwner, repoName, opts)
|
|
if err != nil {
|
|
return fmt.Errorf("could not create issue: %s", err)
|
|
}
|
|
|
|
print.IssueDetails(issue, nil)
|
|
|
|
fmt.Println(issue.HTMLURL)
|
|
|
|
return nil
|
|
}
|