Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Chao <mchao@gitlab.com>2019-01-23 11:50:19 +0300
committerMark Chao <mchao@gitlab.com>2019-03-06 10:50:55 +0300
commit90527b9f842d53595fb14a97a8f8ad19d9dc505a (patch)
treefed26f765da312e42b19e720b94dc3eab7c423b2 /app/controllers/projects/blob_controller.rb
parent154720cadc05d79fd5a89bfec18b9385964447ec (diff)
Add full option for blob diff action
Returns all diff lines for frontend if full is true. Turn UnfoldForm into presenter, and move controller logic to presenter.
Diffstat (limited to 'app/controllers/projects/blob_controller.rb')
-rw-r--r--app/controllers/projects/blob_controller.rb19
1 files changed, 5 insertions, 14 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 77672e7d9fc..63e04539b40 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -90,20 +90,9 @@ class Projects::BlobController < Projects::ApplicationController
def diff
apply_diff_view_cookie!
- @blob.load_all_data!
- @lines = @blob.present.highlight.lines
-
- @form = UnfoldForm.new(params.to_unsafe_h)
-
- @lines = @lines[@form.since - 1..@form.to - 1].map(&:html_safe)
-
- if @form.bottom?
- @match_line = ''
- else
- lines_length = @lines.length - 1
- line = [@form.since, lines_length].join(',')
- @match_line = "@@ -#{line}+#{line} @@"
- end
+ @form = Blobs::UnfoldPresenter.new(blob, params.to_unsafe_h)
+ @lines = @form.lines
+ @match_line = @form.match_line_text
# We can keep only 'render_diff_lines' from this conditional when
# https://gitlab.com/gitlab-org/gitlab-ce/issues/44988 is done
@@ -231,6 +220,8 @@ class Projects::BlobController < Projects::ApplicationController
end
def validate_diff_params
+ return if params[:full]
+
if [:since, :to, :offset].any? { |key| params[key].blank? }
head :ok
end