Skip to content

Commit

Permalink
mr_create: check for empty msg before acting
Browse files Browse the repository at this point in the history
When creating a merge request in draft mode the message size wasn't being
considered: if it was empty, the code would not check and panic due to a
"slice bounds out of range". This patch basically moves the check for
message existence before the actual manipulation code happens.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
  • Loading branch information
bmeneg committed Feb 12, 2021
1 parent 140e43a commit 87b5993
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/mr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ func runMRCreate(cmd *cobra.Command, args []string) {
}
}

if title == "" {
log.Fatal("aborting MR due to empty MR msg")
}

linebreak, _ := cmd.Flags().GetBool("force-linebreak")
if linebreak {
body = textToMarkdown(body)
Expand All @@ -239,10 +243,6 @@ func runMRCreate(cmd *cobra.Command, args []string) {
squash, _ := cmd.Flags().GetBool("squash")
allowCollaboration, _ := cmd.Flags().GetBool("allow-collaboration")

if title == "" {
log.Fatal("aborting MR due to empty MR msg")
}

mrURL, err := lab.MRCreate(sourceProjectName, &gitlab.CreateMergeRequestOptions{
SourceBranch: &branch,
TargetBranch: gitlab.String(targetBranch),
Expand Down

0 comments on commit 87b5993

Please sign in to comment.