diff options
-rw-r--r-- | app/helpers/commits_helper.rb | 12 | ||||
-rw-r--r-- | app/views/projects/commits/_commit.html.haml | 7 |
2 files changed, 13 insertions, 6 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 4d27cf2851e..9643a0a965c 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -180,6 +180,18 @@ module CommitsHelper return old_lines, new_lines end + def link_to_browse_code(project, commit) + if current_controller?(:projects, :commits) + if @repo.blob_at(commit.id, @path) + link_to "Browse File »", project_blob_path(project, tree_join(commit.id, @path)), class: "pull-right" + else + link_to "Browse Dir »", project_tree_path(project, tree_join(commit.id, @path)), class: "pull-right" + end + else + link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right" + end + end + protected # Private: Returns a link to a person. If the person has a matching user and diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index 20fe2688fb4..5adb6b9e3b1 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -7,12 +7,7 @@ - if commit.description? %a.text-expander.js-toggle-button ... - - if @repo && @repo.blob_at(commit.id, @path) - = link_to "Browse File »", project_blob_path(project, tree_join(commit.id, @path)), class: "pull-right" - - elsif @path.blank? - = link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right" - - else - = link_to "Browse Dir »", project_tree_path(project, tree_join(commit.id, @path)), class: "pull-right" + = link_to_browse_code(project, commit) .notes_count - if @note_counts |