2016-11-16 12:28:38 -05:00
|
|
|
module Gitlab
|
|
|
|
module ChatCommands
|
2016-11-17 09:30:04 -05:00
|
|
|
class IssueCreate < IssueCommand
|
2016-11-16 12:28:38 -05:00
|
|
|
def self.match(text)
|
|
|
|
/\Aissue\s+create\s+(?<title>[^\n]*)\n*(?<description>.*)\z/.match(text)
|
|
|
|
end
|
|
|
|
|
2016-11-17 06:57:27 -05:00
|
|
|
def self.help_message
|
|
|
|
'issue create <title>\n<description>'
|
|
|
|
end
|
|
|
|
|
2016-11-17 15:27:12 -05:00
|
|
|
def self.allowed?(project, user)
|
|
|
|
can?(user, :create_issue, project)
|
|
|
|
end
|
2016-11-17 06:06:45 -05:00
|
|
|
|
2016-11-17 15:27:12 -05:00
|
|
|
def execute(match)
|
2016-11-16 12:28:38 -05:00
|
|
|
title = match[:title]
|
|
|
|
description = match[:description]
|
|
|
|
|
2016-11-17 09:30:04 -05:00
|
|
|
Issues::CreateService.new(project, current_user, title: title, description: description).execute
|
2016-11-16 12:28:38 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|