summaryrefslogtreecommitdiff
path: root/lib/gitlab/chat_commands/issue_create.rb
blob: 0e2b4c0e9cde22b401bd2e6cdfc048800e0a0f70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Gitlab
  module ChatCommands
    class IssueCreate < IssueCommand 
      def self.match(text)
        /\Aissue\s+create\s+(?<title>[^\n]*)\n*(?<description>.*)\z/.match(text)
      end

      def self.help_message
        'issue create <title>\n<description>'
      end

      def execute(match)
        present nil unless can?(current_user, :create_issue, project)

        title = match[:title]
        description = match[:description]

        present Issues::CreateService.new(project, current_user, title: title, description: description).execute
      end
    end
  end
end