Commit 0d1ec11e authored by Douwe Maan's avatar Douwe Maan

Use Blob methods instead of BlobHelper helpers

parent 5cb27e9f
......@@ -15,7 +15,7 @@ class Projects::RawController < Projects::ApplicationController
return if cached_blob?
if @blob.lfs_pointer? && project.lfs_enabled?
if @blob.valid_lfs_pointer?
send_lfs_object
else
send_git_blob @repository, @blob
......
......@@ -52,7 +52,7 @@ module BlobHelper
if !on_top_of_branch?(project, ref)
button_tag label, class: "#{common_classes} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: { container: 'body' }
elsif blob.lfs_pointer?
elsif blob.valid_lfs_pointer?
button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' }
elsif can_modify_blob?(blob, project, ref)
button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal'
......@@ -95,7 +95,7 @@ module BlobHelper
end
def can_modify_blob?(blob, project = @project, ref = @ref)
!blob.lfs_pointer? && can_edit_tree?(project, ref)
!blob.valid_lfs_pointer? && can_edit_tree?(project, ref)
end
def leave_edit_message
......@@ -118,22 +118,6 @@ module BlobHelper
icon("#{file_type_icon_class('file', mode, name)} fw")
end
def blob_text_viewable?(blob)
blob && blob.text? && !blob.lfs_pointer? && !blob.only_display_raw?
end
def blob_rendered_as_text?(blob)
blob_text_viewable?(blob) && blob.to_partial_path(@project) == 'text'
end
def blob_size(blob)
if blob.lfs_pointer?
blob.lfs_size
else
blob.size
end
end
def blob_raw_url
namespace_project_raw_path(@project.namespace, @project, @id)
end
......
......@@ -74,7 +74,7 @@
- else
%hr
- blob = diff_file.blob
- if blob && blob.respond_to?(:text?) && blob_text_viewable?(blob)
- if blob && blob.respond_to?(:text?) && blob.readable_text?
%table.code.white
= render partial: "projects/diffs/line", collection: diff_file.highlighted_diff_lines, as: :line, locals: { diff_file: diff_file, plain: true, email: true }
- else
......
......@@ -9,7 +9,7 @@
= copy_file_path_button(blob.path)
%small
= number_to_human_size(blob_size(blob))
= number_to_human_size(blob.raw_size)
.file-actions.hidden-xs
.btn-group{ role: "group" }<
......@@ -19,7 +19,7 @@
.btn-group{ role: "group" }<
-# only show normal/blame view links for text files
- if blob_text_viewable?(blob)
- if blob.readable_text?
- if blame
= link_to 'Normal view', namespace_project_blob_path(@project.namespace, @project, @id),
class: 'btn btn-sm'
......@@ -34,7 +34,7 @@
tree_join(@commit.sha, @path)), class: 'btn btn-sm js-data-file-blob-permalink-url'
.btn-group{ role: "group" }<
= edit_blob_link if blob_text_viewable?(blob)
= edit_blob_link if blob.readable_text?
- if current_user
= replace_blob_link
= delete_blob_link
......
......@@ -3,9 +3,9 @@
- return unless blob.respond_to?(:text?)
- if diff_file.too_large?
.nothing-here-block This diff could not be displayed because it is too large.
- elsif blob.only_display_raw?
- elsif blob.too_large?
.nothing-here-block The file could not be displayed because it is too large.
- elsif blob_text_viewable?(blob)
- elsif blob.readable_text?
- if !project.repository.diffable?(blob)
.nothing-here-block This diff was suppressed by a .gitattributes entry.
- elsif diff_file.collapsed?
......
......@@ -27,7 +27,7 @@
- diff_commit = commit_for_diff(diff_file)
- blob = diff_file.blob(diff_commit)
- next unless blob
- blob.load_all_data!(diffs.project.repository) unless blob.only_display_raw?
- blob.load_all_data!(diffs.project.repository) unless blob.too_large?
- file_hash = hexdigest(diff_file.file_path)
= render 'projects/diffs/file', file_hash: file_hash, project: diffs.project,
......
......@@ -6,7 +6,7 @@
- unless diff_file.submodule?
.file-actions.hidden-xs
- if blob_text_viewable?(blob)
- if blob.readable_text?
= link_to '#', class: 'js-toggle-diff-comments btn active has-tooltip', title: "Toggle comments for this file", disabled: @diff_notes_disabled do
= icon('comment')
\
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment