summaryrefslogtreecommitdiff
path: root/app/services/notes/create_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/notes/create_service.rb')
-rw-r--r--app/services/notes/create_service.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb
index 2bb312bb252..25fcac13540 100644
--- a/app/services/notes/create_service.rb
+++ b/app/services/notes/create_service.rb
@@ -13,5 +13,24 @@ module Notes
note
end
+
+ # An issue can be create from a line comment. This issue has the specified format:
+ #
+ #
+ # ## Title here
+ # ---
+ # description should be here
+ #
+ def new_issue
+ lines = params[:note].lines
+ title = lines[0].gsub(/\A.{3}\W*/, '').rstrip
+ description = lines[2..-1].join('\n').strip # lines[1] == '---' and is thus discarded
+
+ issue = Issues::CreateService.new(project, current_user, title: title, description: description).execute
+ return issue unless issue.valid?
+
+ params[:note] = "#{issue.to_reference} was created from this line comment."
+ execute
+ end
end
end