mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-06 03:08:44 +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>
36 lines
811 B
Go
36 lines
811 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package task
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"code.gitea.io/sdk/gitea"
|
|
|
|
"gitea.dev/tea/modules/config"
|
|
"gitea.dev/tea/modules/print"
|
|
)
|
|
|
|
// CreateMilestone creates a milestone in the given repo and prints the result
|
|
func CreateMilestone(login *config.Login, repoOwner, repoName, title, description string, deadline *time.Time, state gitea.StateType) error {
|
|
// title is required
|
|
if len(title) == 0 {
|
|
return fmt.Errorf("title is required")
|
|
}
|
|
|
|
mile, _, err := login.Client().CreateMilestone(repoOwner, repoName, gitea.CreateMilestoneOption{
|
|
Title: title,
|
|
Description: description,
|
|
Deadline: deadline,
|
|
State: state,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
print.MilestoneDetails(mile)
|
|
return nil
|
|
}
|