summaryrefslogtreecommitdiff
path: root/app/helpers/tree_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/tree_helper.rb')
-rw-r--r--app/helpers/tree_helper.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index e2879bfdcf1..8eed6664e38 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -15,12 +15,12 @@ module TreeHelper
items = (folders + submodules).sort_by(&:name) + files
if items.size > FILE_LIMIT
- tree << render(partial: 'projects/tree/truncated_notice_tree_row',
- locals: { limit: FILE_LIMIT, total: items.size })
+ tree << render(partial: "projects/tree/truncated_notice_tree_row",
+ locals: {limit: FILE_LIMIT, total: items.size})
items = items.take(FILE_LIMIT)
end
- tree << render(partial: 'projects/tree/tree_row', collection: items) if items.present?
+ tree << render(partial: "projects/tree/tree_row", collection: items) if items.present?
tree.join.html_safe
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -31,20 +31,20 @@ module TreeHelper
# mode - File unix mode
# name - File name
def tree_icon(type, mode, name)
- icon([file_type_icon_class(type, mode, name), 'fw'])
+ icon([file_type_icon_class(type, mode, name), "fw"])
end
# Using Rails `*_path` methods can be slow, especially when generating
# many paths, as with a repository tree that has thousands of items.
def fast_project_blob_path(project, blob_path)
ActionDispatch::Journey::Router::Utils.escape_path(
- File.join(relative_url_root, project.path_with_namespace, 'blob', blob_path)
+ File.join(relative_url_root, project.path_with_namespace, "blob", blob_path)
)
end
def fast_project_tree_path(project, tree_path)
ActionDispatch::Journey::Router::Utils.escape_path(
- File.join(relative_url_root, project.path_with_namespace, 'tree', tree_path)
+ File.join(relative_url_root, project.path_with_namespace, "tree", tree_path)
)
end
@@ -73,14 +73,14 @@ module TreeHelper
ref
else
project = tree_edit_project(project)
- project.repository.next_branch('patch')
+ project.repository.next_branch("patch")
end
end
def tree_edit_project(project = @project)
if can?(current_user, :push_code, project)
project
- elsif current_user && current_user.already_forked?(project)
+ elsif current_user&.already_forked?(project)
current_user.fork_of(project)
end
end
@@ -107,7 +107,7 @@ module TreeHelper
branch_name = ERB::Util.html_escape(selected_branch)
message = _("Your changes can be committed to %{branch_name} because a merge "\
- "request is open.") % { branch_name: "<strong>#{branch_name}</strong>" }
+ "request is open.") % {branch_name: "<strong>#{branch_name}</strong>"}
message.html_safe
end
@@ -115,9 +115,9 @@ module TreeHelper
def path_breadcrumbs(max_links = 6)
if @path.present?
part_path = ""
- parts = @path.split('/')
+ parts = @path.split("/")
- yield('..', File.join(*parts.first(parts.count - 2))) if parts.count > max_links
+ yield("..", File.join(*parts.first(parts.count - 2))) if parts.count > max_links
parts.each do |part|
part_path = File.join(part_path, part) unless part_path.empty?
@@ -138,7 +138,7 @@ module TreeHelper
# returns the relative path of the first subdir that doesn't have only one directory descendant
# rubocop: disable CodeReuse/ActiveRecord
def flatten_tree(root_path, tree)
- return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '') if tree.flat_path.present?
+ return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, "") if tree.flat_path.present?
subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path)
if subtree.count == 1 && subtree.first.dir?
@@ -154,6 +154,6 @@ module TreeHelper
end
def relative_url_root
- Gitlab.config.gitlab.relative_url_root.presence || '/'
+ Gitlab.config.gitlab.relative_url_root.presence || "/"
end
end