Class: Gitlab::SlashCommands::IssueComment
- Inherits:
-
IssueCommand
- Object
- BaseCommand
- IssueCommand
- Gitlab::SlashCommands::IssueComment
- Defined in:
- lib/gitlab/slash_commands/issue_comment.rb
Constant Summary
Constants inherited from BaseCommand
Instance Attribute Summary
Attributes inherited from BaseCommand
#chat_name, #current_user, #params, #project
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from IssueCommand
Methods inherited from BaseCommand
allowed?, available?, can?, #collection, #initialize
Constructor Details
This class inherits a constructor from Gitlab::SlashCommands::BaseCommand
Class Method Details
.help_message ⇒ Object
10 11 12 |
# File 'lib/gitlab/slash_commands/issue_comment.rb', line 10 def self. 'issue comment <id> *`⇧ Shift`*+*`↵ Enter`* <comment>' end |
.match(text) ⇒ Object
6 7 8 |
# File 'lib/gitlab/slash_commands/issue_comment.rb', line 6 def self.match(text) /\Aissue\s+comment\s+#{Issue.reference_prefix}?(?<iid>\d+)\n*(?<note_body>(.|\n)*)/.match(text) end |
Instance Method Details
#execute(match) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gitlab/slash_commands/issue_comment.rb', line 14 def execute(match) note_body = match[:note_body].to_s.strip issue = find_by_iid(match[:iid]) return not_found unless issue return access_denied unless can_create_note?(issue) note = create_note(issue: issue, note: note_body) if note.persisted? presenter(note).present else presenter(note).display_errors end end |