2016-11-16 17:28:38 +00:00
|
|
|
module Gitlab
|
|
|
|
module ChatCommands
|
2016-11-17 14:30:04 +00:00
|
|
|
class IssueCreate < IssueCommand
|
2016-11-16 17:28:38 +00:00
|
|
|
def self.match(text)
|
2016-11-21 19:48:18 +00:00
|
|
|
# we can not match \n with the dot by passing the m modifier as than
|
|
|
|
# the title and description are not seperated
|
2016-11-28 12:18:06 +00:00
|
|
|
/\Aissue\s+(new|create)\s+(?<title>[^\n]*)\n*(?<description>(.|\n)*)/.match(text)
|
2016-11-16 17:28:38 +00:00
|
|
|
end
|
|
|
|
|
2016-11-17 11:57:27 +00:00
|
|
|
def self.help_message
|
2016-12-15 13:11:43 +00:00
|
|
|
'issue new <title> *`⇧ Shift`*+*`↵ Enter`* <description>'
|
2016-11-17 11:57:27 +00:00
|
|
|
end
|
|
|
|
|
2016-11-17 20:27:12 +00:00
|
|
|
def self.allowed?(project, user)
|
|
|
|
can?(user, :create_issue, project)
|
|
|
|
end
|
2016-11-17 11:06:45 +00:00
|
|
|
|
2016-11-17 20:27:12 +00:00
|
|
|
def execute(match)
|
2016-11-16 17:28:38 +00:00
|
|
|
title = match[:title]
|
2016-11-21 19:48:18 +00:00
|
|
|
description = match[:description].to_s.rstrip
|
2016-11-16 17:28:38 +00:00
|
|
|
|
2016-11-17 14:30:04 +00:00
|
|
|
Issues::CreateService.new(project, current_user, title: title, description: description).execute
|
2016-11-16 17:28:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|