Commit 79a02df92e18137787371468be5c8897ad2f97b0
1 parent
e33cbb9b
Exists in
master
and in
4 other branches
Update usages of tree_file_project_ref_path to project_tree_path
Showing
20 changed files
with
41 additions
and
36 deletions
Show diff stats
app/controllers/refs_controller.rb
@@ -18,7 +18,7 @@ class RefsController < ApplicationController | @@ -18,7 +18,7 @@ class RefsController < ApplicationController | ||
18 | respond_to do |format| | 18 | respond_to do |format| |
19 | format.html do | 19 | format.html do |
20 | new_path = if params[:destination] == "tree" | 20 | new_path = if params[:destination] == "tree" |
21 | - tree_project_ref_path(@project, params[:ref]) | 21 | + project_tree_path(@project, params[:ref]) |
22 | else | 22 | else |
23 | project_commits_path(@project, ref: params[:ref]) | 23 | project_commits_path(@project, ref: params[:ref]) |
24 | end | 24 | end |
@@ -96,10 +96,10 @@ class RefsController < ApplicationController | @@ -96,10 +96,10 @@ class RefsController < ApplicationController | ||
96 | @hex_path = Digest::SHA1.hexdigest(params[:path] || "/") | 96 | @hex_path = Digest::SHA1.hexdigest(params[:path] || "/") |
97 | 97 | ||
98 | if params[:path] | 98 | if params[:path] |
99 | - @history_path = tree_file_project_ref_path(@project, @ref, params[:path]) | 99 | + @history_path = project_tree_path(@project, File.join(@ref, params[:path])) |
100 | @logs_path = logs_file_project_ref_path(@project, @ref, params[:path]) | 100 | @logs_path = logs_file_project_ref_path(@project, @ref, params[:path]) |
101 | else | 101 | else |
102 | - @history_path = tree_project_ref_path(@project, @ref) | 102 | + @history_path = project_tree_path(@project, @ref) |
103 | @logs_path = logs_tree_project_ref_path(@project, @ref) | 103 | @logs_path = logs_tree_project_ref_path(@project, @ref) |
104 | end | 104 | end |
105 | rescue | 105 | rescue |
app/decorators/tree_decorator.rb
@@ -15,7 +15,7 @@ class TreeDecorator < ApplicationDecorator | @@ -15,7 +15,7 @@ class TreeDecorator < ApplicationDecorator | ||
15 | part_path = part if part_path.empty? | 15 | part_path = part if part_path.empty? |
16 | 16 | ||
17 | next unless parts.last(2).include?(part) if parts.count > max_links | 17 | next unless parts.last(2).include?(part) if parts.count > max_links |
18 | - yield(h.link_to(h.truncate(part, length: 40), h.tree_file_project_ref_path(project, ref, path: part_path), remote: :true)) | 18 | + yield(h.link_to(h.truncate(part, length: 40), h.project_tree_path(project, h.tree_join(ref, part_path)), remote: :true)) |
19 | end | 19 | end |
20 | end | 20 | end |
21 | end | 21 | end |
@@ -26,7 +26,7 @@ class TreeDecorator < ApplicationDecorator | @@ -26,7 +26,7 @@ class TreeDecorator < ApplicationDecorator | ||
26 | 26 | ||
27 | def up_dir_path | 27 | def up_dir_path |
28 | file = File.join(path, "..") | 28 | file = File.join(path, "..") |
29 | - h.tree_file_project_ref_path(project, ref, file) | 29 | + h.project_tree_path(project, h.tree_join(ref, file)) |
30 | end | 30 | end |
31 | 31 | ||
32 | def history_path | 32 | def history_path |
app/helpers/application_helper.rb
@@ -58,11 +58,11 @@ module ApplicationHelper | @@ -58,11 +58,11 @@ module ApplicationHelper | ||
58 | 58 | ||
59 | if @project && !@project.new_record? | 59 | if @project && !@project.new_record? |
60 | project_nav = [ | 60 | project_nav = [ |
61 | - { label: "#{@project.name} / Issues", url: project_issues_path(@project) }, | ||
62 | - { label: "#{@project.name} / Wall", url: wall_project_path(@project) }, | ||
63 | - { label: "#{@project.name} / Tree", url: tree_project_ref_path(@project, @project.root_ref) }, | ||
64 | - { label: "#{@project.name} / Commits", url: project_commits_path(@project) }, | ||
65 | - { label: "#{@project.name} / Team", url: project_team_index_path(@project) } | 61 | + { label: "#{@project.name} / Issues", url: project_issues_path(@project) }, |
62 | + { label: "#{@project.name} / Wall", url: wall_project_path(@project) }, | ||
63 | + { label: "#{@project.name} / Tree", url: project_tree_path(@project, @ref || @project.root_ref) }, | ||
64 | + { label: "#{@project.name} / Commits", url: project_commits_path(@project, @ref || @project.root_ref) }, | ||
65 | + { label: "#{@project.name} / Team", url: project_team_index_path(@project) } | ||
66 | ] | 66 | ] |
67 | end | 67 | end |
68 | 68 |
app/helpers/tree_helper.rb
@@ -39,4 +39,9 @@ module TreeHelper | @@ -39,4 +39,9 @@ module TreeHelper | ||
39 | def gitlab_markdown?(filename) | 39 | def gitlab_markdown?(filename) |
40 | filename.end_with?(*%w(.mdown .md .markdown)) | 40 | filename.end_with?(*%w(.mdown .md .markdown)) |
41 | end | 41 | end |
42 | + | ||
43 | + # Simple shortcut to File.join | ||
44 | + def tree_join(*args) | ||
45 | + File.join(*args) | ||
46 | + end | ||
42 | end | 47 | end |
app/views/commits/_commit.html.haml
1 | %li.commit | 1 | %li.commit |
2 | .browse_code_link_holder | 2 | .browse_code_link_holder |
3 | %p | 3 | %p |
4 | - %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit), class: "right" | 4 | + %strong= link_to "Browse Code »", project_tree_path(@project, commit), class: "right" |
5 | %p | 5 | %p |
6 | = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" | 6 | = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" |
7 | %strong.commit-author-name= commit.author_name | 7 | %strong.commit-author-name= commit.author_name |
app/views/commits/_commit_box.html.haml
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | = link_to patch_project_commit_path(@project, @commit.id), class: "btn small grouped" do | 8 | = link_to patch_project_commit_path(@project, @commit.id), class: "btn small grouped" do |
9 | %i.icon-download-alt | 9 | %i.icon-download-alt |
10 | Get Patch | 10 | Get Patch |
11 | - = link_to tree_project_ref_path(@project, @commit.id), class: "browse-button primary grouped" do | 11 | + = link_to project_tree_path(@project, @commit), class: "browse-button primary grouped" do |
12 | %strong Browse Code » | 12 | %strong Browse Code » |
13 | %h3.commit-title.page_title | 13 | %h3.commit-title.page_title |
14 | = gfm escape_once(@commit.title) | 14 | = gfm escape_once(@commit.title) |
app/views/commits/_diffs.html.haml
@@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
24 | %i.icon-file | 24 | %i.icon-file |
25 | %span{id: "#{diff.old_path}"}= diff.old_path | 25 | %span{id: "#{diff.old_path}"}= diff.old_path |
26 | - else | 26 | - else |
27 | - = link_to tree_file_project_ref_path(@project, @commit.id, diff.new_path) do | 27 | + = link_to project_tree_path(@project, @commit, diff.new_path) do |
28 | %i.icon-file | 28 | %i.icon-file |
29 | %span{id: "#{diff.new_path}"}= diff.new_path | 29 | %span{id: "#{diff.new_path}"}= diff.new_path |
30 | %br/ | 30 | %br/ |
app/views/layouts/_head.html.haml
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | - if controller_name == 'projects' && action_name == 'index' | 10 | - if controller_name == 'projects' && action_name == 'index' |
11 | = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" | 11 | = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" |
12 | - if @project && !@project.new_record? | 12 | - if @project && !@project.new_record? |
13 | - - if current_page?(tree_project_ref_path(@project, @project.root_ref)) || current_page?(project_commits_path(@project)) | 13 | + - if current_page?(project_tree_path(@project, @project.root_ref)) || current_page?(project_commits_path(@project)) |
14 | = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, ref: @ref, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") | 14 | = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, ref: @ref, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") |
15 | - if request.path == project_issues_path(@project) | 15 | - if request.path == project_issues_path(@project) |
16 | = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") | 16 | = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") |
app/views/layouts/_project_menu.html.haml
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | - if @project.repo_exists? | 5 | - if @project.repo_exists? |
6 | - if can? current_user, :download_code, @project | 6 | - if can? current_user, :download_code, @project |
7 | %li{class: tree_tab_class} | 7 | %li{class: tree_tab_class} |
8 | - = link_to tree_project_ref_path(@project, @project.root_ref) do | 8 | + = link_to project_tree_path(@project, @project.root_ref) do |
9 | Files | 9 | Files |
10 | %li{class: commit_tab_class} | 10 | %li{class: commit_tab_class} |
11 | = link_to "Commits", project_commits_path(@project) | 11 | = link_to "Commits", project_commits_path(@project) |
app/views/refs/_head.html.haml
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | %li | 2 | %li |
3 | = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} | 3 | = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} |
4 | %li{class: "#{'active' if (controller.controller_name == "refs") }"} | 4 | %li{class: "#{'active' if (controller.controller_name == "refs") }"} |
5 | - = link_to tree_project_ref_path(@project, @ref) do | 5 | + = link_to project_tree_path(@project, @ref) do |
6 | Source | 6 | Source |
7 | %li.right | 7 | %li.right |
8 | .input-prepend.project_clone_holder | 8 | .input-prepend.project_clone_holder |
app/views/refs/blame.html.haml
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | %ul.breadcrumb | 4 | %ul.breadcrumb |
5 | %li | 5 | %li |
6 | %span.arrow | 6 | %span.arrow |
7 | - = link_to tree_project_ref_path(@project, @ref, path: nil) do | 7 | + = link_to project_tree_path(@project, @ref) do |
8 | = @project.name | 8 | = @project.name |
9 | - @tree.breadcrumbs(6) do |link| | 9 | - @tree.breadcrumbs(6) do |link| |
10 | \/ | 10 | \/ |
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | %span.options | 20 | %span.options |
21 | = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" | 21 | = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" |
22 | = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" | 22 | = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" |
23 | - = link_to "source", tree_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small" | 23 | + = link_to "source", project_tree_path(@project, tree_join(@ref, params[:path])), class: "btn very_small" |
24 | .file_content.blame | 24 | .file_content.blame |
25 | %table | 25 | %table |
26 | - @blame.each do |commit, lines| | 26 | - @blame.each do |commit, lines| |
app/views/refs/logs_tree.js.haml
@@ -6,4 +6,4 @@ | @@ -6,4 +6,4 @@ | ||
6 | :plain | 6 | :plain |
7 | var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); | 7 | var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); |
8 | row.find("td.tree_time_ago").html('#{escape_javascript(time_ago_in_words(content_commit.committed_date))} ago'); | 8 | row.find("td.tree_time_ago").html('#{escape_javascript(time_ago_in_words(content_commit.committed_date))} ago'); |
9 | - row.find("td.tree_commit").html('#{escape_javascript(render("tree_commit", tm: tm, content_commit: content_commit))}'); | 9 | + row.find("td.tree_commit").html('#{escape_javascript(render("tree/tree_commit", tm: tm, content_commit: content_commit))}'); |
app/views/tree/_head.html.haml
1 | %ul.nav.nav-tabs | 1 | %ul.nav.nav-tabs |
2 | %li | 2 | %li |
3 | = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} | 3 | = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} |
4 | - %li{class: "#{'active' if (controller.controller_name == "refs") }"} | ||
5 | - = link_to tree_project_ref_path(@project, @ref) do | 4 | + %li{class: "#{'active' if (controller.controller_name == "tree") }"} |
5 | + = link_to project_tree_path(@project, @ref) do | ||
6 | Source | 6 | Source |
7 | %li.right | 7 | %li.right |
8 | .input-prepend.project_clone_holder | 8 | .input-prepend.project_clone_holder |
app/views/tree/_tree.html.haml
1 | %ul.breadcrumb | 1 | %ul.breadcrumb |
2 | %li | 2 | %li |
3 | %span.arrow | 3 | %span.arrow |
4 | - = link_to tree_project_ref_path(@project, @ref, path: nil), remote: true do | 4 | + = link_to project_tree_path(@project, @ref), remote: true do |
5 | = @project.name | 5 | = @project.name |
6 | - tree.breadcrumbs(6) do |link| | 6 | - tree.breadcrumbs(6) do |link| |
7 | \/ | 7 | \/ |
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | %div.tree_progress | 10 | %div.tree_progress |
11 | #tree-content-holder | 11 | #tree-content-holder |
12 | - if tree.is_blob? | 12 | - if tree.is_blob? |
13 | - = render partial: "refs/tree_file", locals: { name: tree.name, content: tree.data, file: tree } | 13 | + = render partial: "tree/tree_file", locals: { name: tree.name, content: tree.data, file: tree } |
14 | - else | 14 | - else |
15 | - contents = tree.contents | 15 | - contents = tree.contents |
16 | %table#tree-slider{class: "table_#{@hex_path}" } | 16 | %table#tree-slider{class: "table_#{@hex_path}" } |
@@ -31,11 +31,11 @@ | @@ -31,11 +31,11 @@ | ||
31 | 31 | ||
32 | - index = 0 | 32 | - index = 0 |
33 | - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content| | 33 | - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content| |
34 | - = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) } | 34 | + = render partial: "tree/tree_item", locals: { content: content, index: (index += 1) } |
35 | - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content| | 35 | - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content| |
36 | - = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) } | 36 | + = render partial: "tree/tree_item", locals: { content: content, index: (index += 1) } |
37 | - contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content| | 37 | - contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content| |
38 | - = render partial: "refs/submodule_item", locals: { content: content, index: (index += 1) } | 38 | + = render partial: "tree/submodule_item", locals: { content: content, index: (index += 1) } |
39 | 39 | ||
40 | - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first | 40 | - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first |
41 | .file_holder#README | 41 | .file_holder#README |
app/views/tree/_tree_file.html.haml
@@ -5,9 +5,9 @@ | @@ -5,9 +5,9 @@ | ||
5 | = name.force_encoding('utf-8') | 5 | = name.force_encoding('utf-8') |
6 | %small #{file.mode} | 6 | %small #{file.mode} |
7 | %span.options | 7 | %span.options |
8 | - = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" | 8 | + = link_to "raw", blob_project_ref_path(@project, @ref, path: @path), class: "btn very_small", target: "_blank" |
9 | = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" | 9 | = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" |
10 | - = link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small" | 10 | + = link_to "blame", blame_file_project_ref_path(@project, @ref, path: @path.gsub(/^\//, '')), class: "btn very_small" |
11 | - if file.text? | 11 | - if file.text? |
12 | - if gitlab_markdown?(name) | 12 | - if gitlab_markdown?(name) |
13 | .file_content.wiki | 13 | .file_content.wiki |
app/views/tree/_tree_item.html.haml
1 | - file = tree_full_path(content) | 1 | - file = tree_full_path(content) |
2 | -%tr{ class: "tree-item #{tree_hex_class(content)}", url: tree_file_project_ref_path(@project, @ref, file) } | 2 | +%tr{ class: "tree-item #{tree_hex_class(content)}", url: project_tree_path(@project, tree_join(@id, file)) } |
3 | %td.tree-item-file-name | 3 | %td.tree-item-file-name |
4 | = tree_icon(content) | 4 | = tree_icon(content) |
5 | - %strong= link_to truncate(content.name, length: 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), remote: :true | 5 | + %strong= link_to truncate(content.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, file)), remote: :true |
6 | %td.tree_time_ago.cgray | 6 | %td.tree_time_ago.cgray |
7 | - if index == 1 | 7 | - if index == 1 |
8 | %span.log_loading | 8 | %span.log_loading |
features/steps/project/project_browse_files.rb
@@ -10,7 +10,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps | @@ -10,7 +10,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps | ||
10 | end | 10 | end |
11 | 11 | ||
12 | Then 'I should see files from repository for "8470d70"' do | 12 | Then 'I should see files from repository for "8470d70"' do |
13 | - current_path.should == tree_project_ref_path(@project, "8470d70") | 13 | + current_path.should == project_tree_path(@project, "8470d70") |
14 | page.should have_content "app" | 14 | page.should have_content "app" |
15 | page.should have_content "History" | 15 | page.should have_content "History" |
16 | page.should have_content "Gemfile" | 16 | page.should have_content "Gemfile" |
features/steps/shared/paths.rb
@@ -51,15 +51,15 @@ module SharedPaths | @@ -51,15 +51,15 @@ module SharedPaths | ||
51 | end | 51 | end |
52 | 52 | ||
53 | Given 'I visit project source page' do | 53 | Given 'I visit project source page' do |
54 | - visit tree_project_ref_path(@project, @project.root_ref) | 54 | + visit project_tree_path(@project, @project.root_ref) |
55 | end | 55 | end |
56 | 56 | ||
57 | Given 'I visit blob file from repo' do | 57 | Given 'I visit blob file from repo' do |
58 | - visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH) | 58 | + visit project_tree_path(@project, File.join(ValidCommit::ID, ValidCommit::BLOB_FILE_PATH)) |
59 | end | 59 | end |
60 | 60 | ||
61 | Given 'I visit project source page for "8470d70"' do | 61 | Given 'I visit project source page for "8470d70"' do |
62 | - visit tree_project_ref_path(@project, "8470d70") | 62 | + visit project_tree_path(@project, "8470d70") |
63 | end | 63 | end |
64 | 64 | ||
65 | Given 'I visit project tags page' do | 65 | Given 'I visit project tags page' do |
spec/requests/gitlab_flavored_markdown_spec.rb
@@ -61,7 +61,7 @@ describe "Gitlab Flavored Markdown" do | @@ -61,7 +61,7 @@ describe "Gitlab Flavored Markdown" do | ||
61 | end | 61 | end |
62 | 62 | ||
63 | it "should render title in refs#tree", js: true do | 63 | it "should render title in refs#tree", js: true do |
64 | - visit tree_project_ref_path(project, id: @branch_name) | 64 | + visit project_tree_path(project, @branch_name) |
65 | 65 | ||
66 | within(".tree_commit") do | 66 | within(".tree_commit") do |
67 | page.should have_link("##{issue.id}") | 67 | page.should have_link("##{issue.id}") |
spec/requests/security/project_access_spec.rb
@@ -37,7 +37,7 @@ describe "Application access" do | @@ -37,7 +37,7 @@ describe "Application access" do | ||
37 | end | 37 | end |
38 | 38 | ||
39 | describe "GET /project_code/master/tree" do | 39 | describe "GET /project_code/master/tree" do |
40 | - subject { tree_project_ref_path(@project, @project.root_ref) } | 40 | + subject { project_tree_path(@project, @project.root_ref) } |
41 | 41 | ||
42 | it { should be_allowed_for @u1 } | 42 | it { should be_allowed_for @u1 } |
43 | it { should be_allowed_for @u3 } | 43 | it { should be_allowed_for @u3 } |