Skip to content

Commit

Permalink
issue_create: Add --milestone option
Browse files Browse the repository at this point in the history
Like labels, milestones are useful for both merge requests and issues,
so add a corresponding option to the issue_create command.
  • Loading branch information
fmuellner committed Jan 12, 2021
1 parent 6cbbe1b commit e068d19
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/issue_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ var issueCreateCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
milestoneName, err := cmd.Flags().GetString("milestone")
if err != nil {
log.Fatal(err)
}
templateName, err := cmd.Flags().GetString("template")
if err != nil {
log.Fatal(err)
Expand All @@ -62,6 +66,15 @@ var issueCreateCmd = &cobra.Command{
log.Fatal(err)
}

var milestoneID *int
if milestoneName != "" {
milestone, err := lab.MilestoneGet(rn, milestoneName)
if err != nil {
log.Fatal(err)
}
milestoneID = &milestone.ID
}

title, body, err := issueMsg(templateName, msgs)
if err != nil {
_, f, l, _ := runtime.Caller(0)
Expand All @@ -86,6 +99,7 @@ var issueCreateCmd = &cobra.Command{
Description: &body,
Labels: labels,
AssigneeIDs: assigneeIDs,
MilestoneID: milestoneID,
})
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -148,6 +162,7 @@ func init() {
issueCreateCmd.Flags().StringArrayP("message", "m", []string{}, "use the given <msg>; multiple -m are concatenated as separate paragraphs")
issueCreateCmd.Flags().StringSliceP("label", "l", []string{}, "set the given label(s) on the created issue")
issueCreateCmd.Flags().StringSliceP("assignees", "a", []string{}, "set assignees by username")
issueCreateCmd.Flags().String("milestone", "", "set milestone by title")
issueCreateCmd.Flags().StringP("template", "t", "default", "use the given issue template")
issueCreateCmd.Flags().Bool("force-linebreak", false, "append 2 spaces to the end of each line to force markdown linebreaks")

Expand Down

0 comments on commit e068d19

Please sign in to comment.