Skip to content

Commit

Permalink
mr_create: Allow creating draft merge request
Browse files Browse the repository at this point in the history
As with the edit subcommand, an explicit option is more convenient
than prefixing the title manually.
  • Loading branch information
fmuellner authored and prarit committed Dec 14, 2020
1 parent 4b72ab8 commit 87cd0bb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/mr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func init() {
mrCreateCmd.Flags().StringP("file", "F", "", "use the given file as the Description")
mrCreateCmd.Flags().Bool("force-linebreak", false, "append 2 spaces to the end of each line to force markdown linebreaks")
mrCreateCmd.Flags().BoolP("cover-letter", "c", false, "do not comment changelog and diffstat")
mrCreateCmd.Flags().Bool("draft", false, "mark the merge request as draft")
mergeRequestCmd.Flags().AddFlagSet(mrCreateCmd.Flags())

mrCmd.AddCommand(mrCreateCmd)
Expand Down Expand Up @@ -198,6 +199,18 @@ func runMRCreate(cmd *cobra.Command, args []string) {
body = textToMarkdown(body)
}

draft, _ := cmd.Flags().GetBool("draft")
if draft {
isWIP := strings.EqualFold(title[0:4], "wip:")
isDraft := strings.EqualFold(title[0:6], "draft:") ||
strings.EqualFold(title[0:7], "[draft]") ||
strings.EqualFold(title[0:7], "(draft)")

if !isWIP && !isDraft {
title = "Draft: " + title
}
}

removeSourceBranch, _ := cmd.Flags().GetBool("remove-source-branch")
squash, _ := cmd.Flags().GetBool("squash")
allowCollaboration, _ := cmd.Flags().GetBool("allow-collaboration")
Expand Down

0 comments on commit 87cd0bb

Please sign in to comment.