Commit a713c9c1 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'zj-fix-trailing-whitespace-issue-create' into 'master'

Issue creation now accepts trailing whitespace

See merge request !7633
parents dfb21e29 3ff05756
...@@ -2,7 +2,9 @@ module Gitlab ...@@ -2,7 +2,9 @@ module Gitlab
module ChatCommands module ChatCommands
class IssueCreate < IssueCommand class IssueCreate < IssueCommand
def self.match(text) def self.match(text)
/\Aissue\s+create\s+(?<title>[^\n]*)\n*(?<description>.*)\z/.match(text) # we can not match \n with the dot by passing the m modifier as than
# the title and description are not seperated
/\Aissue\s+create\s+(?<title>[^\n]*)\n*(?<description>(.|\n)*)/.match(text)
end end
def self.help_message def self.help_message
...@@ -15,7 +17,7 @@ module Gitlab ...@@ -15,7 +17,7 @@ module Gitlab
def execute(match) def execute(match)
title = match[:title] title = match[:title]
description = match[:description] description = match[:description].to_s.rstrip
Issues::CreateService.new(project, current_user, title: title, description: description).execute Issues::CreateService.new(project, current_user, title: title, description: description).execute
end end
......
...@@ -32,6 +32,15 @@ describe Gitlab::ChatCommands::IssueCreate, service: true do ...@@ -32,6 +32,15 @@ describe Gitlab::ChatCommands::IssueCreate, service: true do
expect(Issue.last.description).to eq(description) expect(Issue.last.description).to eq(description)
end end
end end
context "with more newlines between the title and the description" do
let(:description) { "Surfin bird" }
let(:regex_match) { described_class.match("issue create bird is the word\n\n#{description}\n") }
it 'creates the issue' do
expect { subject }.to change { project.issues.count }.by(1)
end
end
end end
describe '.match' do describe '.match' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment