gitlab-org--gitlab-foss/lib/gitlab/chat_commands/issue_create.rb

27 lines
778 B
Ruby
Raw Normal View History

module Gitlab
module ChatCommands
2016-11-17 14:30:04 +00:00
class IssueCreate < IssueCommand
def self.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+(new|create)\s+(?<title>[^\n]*)\n*(?<description>(.|\n)*)/.match(text)
end
2016-11-17 11:57:27 +00:00
def self.help_message
'issue new <title> *`⇧ Shift`*+*`↵ Enter`* <description>'
2016-11-17 11:57:27 +00:00
end
def self.allowed?(project, user)
can?(user, :create_issue, project)
end
def execute(match)
title = match[:title]
description = match[:description].to_s.rstrip
2016-11-17 14:30:04 +00:00
Issues::CreateService.new(project, current_user, title: title, description: description).execute
end
end
end
end