diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-24 12:28:43 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-30 10:44:18 +0200 |
commit | 701976e0815c273ff4a4c6e4d3489db0ce2f0860 (patch) | |
tree | e519cfebe16a9684bb6162421c2be159243142ba /app/services/issues | |
parent | cff3497f2c06dd4e1785af3c844040ed7939dcb0 (diff) | |
download | gitlab-ce-701976e0815c273ff4a4c6e4d3489db0ce2f0860.tar.gz |
Add uploads rewriter and use it when moving issue
Diffstat (limited to 'app/services/issues')
-rw-r--r-- | app/services/issues/move_service.rb | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index a5efb21fab6..e15e25ee536 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -43,7 +43,7 @@ module Issues def create_new_issue new_params = { id: nil, iid: nil, label_ids: [], milestone: nil, project: @new_project, author: @old_issue.author, - description: unfold_references(@old_issue.description) } + description: rewrite_content(@old_issue.description) } new_params = @old_issue.serializable_hash.merge(new_params) CreateService.new(@new_project, @current_user, new_params).execute @@ -53,7 +53,7 @@ module Issues @old_issue.notes.find_each do |note| new_note = note.dup new_params = { project: @new_project, noteable: @new_issue, - note: unfold_references(new_note.note), + note: rewrite_content(new_note.note), created_at: note.created_at, updated_at: note.updated_at } @@ -61,6 +61,29 @@ module Issues end end + def rewrite_content(content) + rewrite_uploads( + unfold_references(content) + ) + end + + def unfold_references(content) + return unless content + + rewriter = Gitlab::Gfm::ReferenceRewriter.new(content, @old_project, + @current_user) + rewriter.rewrite(@new_project) + end + + def rewrite_uploads(content) + return unless content + + rewriter = Gitlab::Gfm::UploadsRewriter.new(content, @old_project, + @current_user) + return content unless rewriter.has_uploads? + rewriter.rewrite(@new_project) + end + def close_issue close_service = CloseService.new(@old_project, @current_user) close_service.execute(@old_issue, notifications: false, system_note: false) @@ -78,20 +101,12 @@ module Issues direction: :to) end - def unfold_references(content) - return unless content - - rewriter = Gitlab::Gfm::ReferenceRewriter.new(content, @old_project, - @current_user) - rewriter.rewrite(@new_project) + def mark_as_moved + @old_issue.update(moved_to: @new_issue) end def notify_participants notification_service.issue_moved(@old_issue, @new_issue, @current_user) end - - def mark_as_moved - @old_issue.update(moved_to: @new_issue) - end end end |