diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2016-08-17 17:02:17 +0200 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2016-08-17 17:07:08 +0200 |
commit | cd814fbc0269a37a028f8285aa9bc45e2a6e5ab3 (patch) | |
tree | 92fbe5d747d195fee19933cbbb3bf70dbeeef87f | |
parent | 83bbca26f48242461606f76f69f3e3bb462666d0 (diff) | |
download | gitlab-ce-fix/eliminate-unneeded-calls-to-repository-blob-at.tar.gz |
Eliminate unneeded calls to Repository#blob_at when listing commits with no pathfix/eliminate-unneeded-calls-to-repository-blob-at
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/helpers/commits_helper.rb | 45 |
2 files changed, 25 insertions, 21 deletions
diff --git a/CHANGELOG b/CHANGELOG index 837e9e27aba..9dddd4856b8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -120,6 +120,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 - Upgrade Rails to 4.2.7.1 for security fixes. !5781 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) |