summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-08-17 16:26:00 +0000
committerRuben Davila <rdavila84@gmail.com>2016-08-17 15:18:11 -0500
commit6505a994375e72ab7d400452d9f03dabcb7a0676 (patch)
treebc48f5eba8f9f7f5941e2141d7aacc0944f588da
parentb09be7487a8a29104132f62bd24208d505102007 (diff)
downloadgitlab-ce-6505a994375e72ab7d400452d9f03dabcb7a0676.tar.gz
Merge branch 'fix/eliminate-unneeded-calls-to-repository-blob-at' into 'master'
Eliminate unneeded calls to Repository#blob_at when listing commits with no path See merge request !5848
-rw-r--r--CHANGELOG1
-rw-r--r--app/helpers/commits_helper.rb45
2 files changed, 25 insertions, 21 deletions
diff --git a/CHANGELOG b/CHANGELOG
index bdc27d77a1a..f0f804735e1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -121,6 +121,7 @@ v 8.11.0 (unreleased)
- Fix a memory leak caused by Banzai::Filter::SanitizationFilter
- Speed up todos queries by limiting the projects set we join with
- Ensure file editing in UI does not overwrite commited changes without warning user
+ - Eliminate unneeded calls to Repository#blob_at when listing commits with no path
v 8.10.6 (unreleased)
- Fix import/export configuration missing some included attributes
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 7a02d0b10d9..33dcee49aee 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -98,28 +98,31 @@ module CommitsHelper
end
def link_to_browse_code(project, commit)
- if current_controller?(:projects, :commits)
- if @repo.blob_at(commit.id, @path)
- return link_to(
- "Browse File",
- namespace_project_blob_path(project.namespace, project,
- tree_join(commit.id, @path)),
- class: "btn btn-default"
- )
- elsif @path.present?
- return link_to(
- "Browse Directory",
- namespace_project_tree_path(project.namespace, project,
- tree_join(commit.id, @path)),
- class: "btn btn-default"
- )
- end
+ if @path.blank?
+ return link_to(
+ "Browse Files",
+ namespace_project_tree_path(project.namespace, project, commit),
+ class: "btn btn-default"
+ )
+ end
+
+ return unless current_controller?(:projects, :commits)
+
+ if @repo.blob_at(commit.id, @path)
+ return link_to(
+ "Browse File",
+ namespace_project_blob_path(project.namespace, project,
+ tree_join(commit.id, @path)),
+ class: "btn btn-default"
+ )
+ elsif @path.present?
+ return link_to(
+ "Browse Directory",
+ namespace_project_tree_path(project.namespace, project,
+ tree_join(commit.id, @path)),
+ class: "btn btn-default"
+ )
end
- link_to(
- "Browse Files",
- namespace_project_tree_path(project.namespace, project, commit),
- class: "btn btn-default"
- )
end
def revert_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true)