##// END OF EJS Templates
Fixed: Links to repository directories don't work (#1119)....
Jean-Philippe Lang -
r1350:a73f68a185df
parent child
Show More
@@ -65,7 +65,8 class RepositoriesController < ApplicationController
65 if request.xhr?
65 if request.xhr?
66 @entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
66 @entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
67 else
67 else
68 show_error_not_found unless @entries
68 show_error_not_found and return unless @entries
69 render :action => 'browse'
69 end
70 end
70 rescue Redmine::Scm::Adapters::CommandFailed => e
71 rescue Redmine::Scm::Adapters::CommandFailed => e
71 show_error_command_failed(e.message)
72 show_error_command_failed(e.message)
@@ -95,6 +96,12 class RepositoriesController < ApplicationController
95 end
96 end
96
97
97 def entry
98 def entry
99 @entry = @repository.scm.entry(@path, @rev)
100 show_error_not_found and return unless @entry
101
102 # If the entry is a dir, show the browser
103 browse and return if @entry.is_dir?
104
98 @content = @repository.scm.cat(@path, @rev)
105 @content = @repository.scm.cat(@path, @rev)
99 show_error_not_found and return unless @content
106 show_error_not_found and return unless @content
100 if 'raw' == params[:format] || @content.is_binary_data?
107 if 'raw' == params[:format] || @content.is_binary_data?
@@ -59,8 +59,17 module Redmine
59 # Returns the entry identified by path and revision identifier
59 # Returns the entry identified by path and revision identifier
60 # or nil if entry doesn't exist in the repository
60 # or nil if entry doesn't exist in the repository
61 def entry(path=nil, identifier=nil)
61 def entry(path=nil, identifier=nil)
62 e = entries(path, identifier)
62 parts = path.to_s.split(%r{[\/\\]}).select {|n| !n.blank?}
63 e ? e.first : nil
63 search_path = parts[0..-2].join('/')
64 search_name = parts[-1]
65 if search_path.blank? && search_name.blank?
66 # Root entry
67 Entry.new(:path => '', :kind => 'dir')
68 else
69 # Search for the entry in the parent directory
70 es = entries(search_path, identifier)
71 es ? es.detect {|e| e.name == search_name} : nil
72 end
64 end
73 end
65
74
66 # Returns an Entries collection
75 # Returns an Entries collection
@@ -44,18 +44,6 module Redmine
44 return nil
44 return nil
45 end
45 end
46
46
47 # Returns the entry identified by path and revision identifier
48 # or nil if entry doesn't exist in the repository
49 def entry(path=nil, identifier=nil)
50 path ||= ''
51 parts = path.split(%r{[\/\\]}).select {|p| !p.blank?}
52 if parts.size > 0
53 parent = parts[0..-2].join('/')
54 entries = entries(parent, identifier)
55 entries ? entries.detect {|e| e.name == parts.last} : nil
56 end
57 end
58
59 # Returns an Entries collection
47 # Returns an Entries collection
60 # or nil if the given path doesn't exist in the repository
48 # or nil if the given path doesn't exist in the repository
61 def entries(path=nil, identifier=nil)
49 def entries(path=nil, identifier=nil)
@@ -55,15 +55,6 module Redmine
55 def get_previous_revision(revision)
55 def get_previous_revision(revision)
56 CvsRevisionHelper.new(revision).prevRev
56 CvsRevisionHelper.new(revision).prevRev
57 end
57 end
58
59 # Returns the entry identified by path and revision identifier
60 # or nil if entry doesn't exist in the repository
61 # this method returns all revisions from one single SCM-Entry
62 def entry(path=nil, identifier="HEAD")
63 e = entries(path, identifier)
64 logger.debug("<cvs-result> #{e.first.inspect}") if e
65 e ? e.first : nil
66 end
67
58
68 # Returns an Entries collection
59 # Returns an Entries collection
69 # or nil if the given path doesn't exist in the repository
60 # or nil if the given path doesn't exist in the repository
@@ -40,13 +40,6 module Redmine
40 rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil
40 rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil
41 end
41 end
42
42
43 # Returns the entry identified by path and revision identifier
44 # or nil if entry doesn't exist in the repository
45 def entry(path=nil, identifier=nil)
46 e = entries(path, identifier)
47 e ? e.first : nil
48 end
49
50 # Returns an Entries collection
43 # Returns an Entries collection
51 # or nil if the given path doesn't exist in the repository
44 # or nil if the given path doesn't exist in the repository
52 def entries(path=nil, identifier=nil)
45 def entries(path=nil, identifier=nil)
@@ -132,14 +132,6 module Redmine
132 entries.sort_by_name
132 entries.sort_by_name
133 end
133 end
134
134
135 def entry(path=nil, identifier=nil)
136 path ||= ''
137 search_path = path.split('/')[0..-2].join('/')
138 entry_name = path.split('/').last
139 e = entries(search_path, identifier)
140 e ? e.detect{|entry| entry.name == entry_name} : nil
141 end
142
143 def revisions(path, identifier_from, identifier_to, options={})
135 def revisions(path, identifier_from, identifier_to, options={})
144 revisions = Revisions.new
136 revisions = Revisions.new
145 cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw "
137 cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw "
@@ -59,14 +59,6 module Redmine
59 return nil if $? && $?.exitstatus != 0
59 return nil if $? && $?.exitstatus != 0
60 entries.sort_by_name
60 entries.sort_by_name
61 end
61 end
62
63 def entry(path=nil, identifier=nil)
64 path ||= ''
65 search_path = path.split('/')[0..-2].join('/')
66 entry_name = path.split('/').last
67 e = entries(search_path, identifier)
68 e ? e.detect{|entry| entry.name == entry_name} : nil
69 end
70
62
71 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
63 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
72 revisions = Revisions.new
64 revisions = Revisions.new
@@ -51,13 +51,6 module Redmine
51 return nil
51 return nil
52 end
52 end
53
53
54 # Returns the entry identified by path and revision identifier
55 # or nil if entry doesn't exist in the repository
56 def entry(path=nil, identifier=nil)
57 e = entries(path, identifier)
58 e ? e.first : nil
59 end
60
61 # Returns an Entries collection
54 # Returns an Entries collection
62 # or nil if the given path doesn't exist in the repository
55 # or nil if the given path doesn't exist in the repository
63 def entries(path=nil, identifier=nil)
56 def entries(path=nil, identifier=nil)
@@ -99,6 +99,14 class RepositoriesBazaarControllerTest < Test::Unit::TestCase
99 assert @response.body.include?('Show help message')
99 assert @response.body.include?('Show help message')
100 end
100 end
101
101
102 def test_directory_entry
103 get :entry, :id => 3, :path => ['directory']
104 assert_response :success
105 assert_template 'browse'
106 assert_not_nil assigns(:entry)
107 assert_equal 'directory', assigns(:entry).name
108 end
109
102 def test_diff
110 def test_diff
103 # Full diff of changeset 3
111 # Full diff of changeset 3
104 get :diff, :id => 3, :rev => 3
112 get :diff, :id => 3, :rev => 3
@@ -101,6 +101,14 class RepositoriesCvsControllerTest < Test::Unit::TestCase
101 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
101 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
102 assert_response :success
102 assert_response :success
103 end
103 end
104
105 def test_directory_entry
106 get :entry, :id => 1, :path => ['sources']
107 assert_response :success
108 assert_template 'browse'
109 assert_not_nil assigns(:entry)
110 assert_equal 'sources', assigns(:entry).name
111 end
104
112
105 def test_diff
113 def test_diff
106 Project.find(1).repository.fetch_changesets
114 Project.find(1).repository.fetch_changesets
@@ -101,6 +101,14 class RepositoriesGitControllerTest < Test::Unit::TestCase
101 assert @response.body.include?('WITHOUT ANY WARRANTY')
101 assert @response.body.include?('WITHOUT ANY WARRANTY')
102 end
102 end
103
103
104 def test_directory_entry
105 get :entry, :id => 3, :path => ['sources']
106 assert_response :success
107 assert_template 'browse'
108 assert_not_nil assigns(:entry)
109 assert_equal 'sources', assigns(:entry).name
110 end
111
104 def test_diff
112 def test_diff
105 # Full diff of changeset 2f9c0091
113 # Full diff of changeset 2f9c0091
106 get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
114 get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
@@ -99,7 +99,15 class RepositoriesMercurialControllerTest < Test::Unit::TestCase
99 # File content
99 # File content
100 assert @response.body.include?('WITHOUT ANY WARRANTY')
100 assert @response.body.include?('WITHOUT ANY WARRANTY')
101 end
101 end
102
102
103 def test_directory_entry
104 get :entry, :id => 3, :path => ['sources']
105 assert_response :success
106 assert_template 'browse'
107 assert_not_nil assigns(:entry)
108 assert_equal 'sources', assigns(:entry).name
109 end
110
103 def test_diff
111 def test_diff
104 # Full diff of changeset 4
112 # Full diff of changeset 4
105 get :diff, :id => 3, :rev => 4
113 get :diff, :id => 3, :rev => 4
@@ -89,6 +89,14 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
89 assert_response :success
89 assert_response :success
90 end
90 end
91
91
92 def test_directory_entry
93 get :entry, :id => 1, :path => ['subversion_test', 'folder']
94 assert_response :success
95 assert_template 'browse'
96 assert_not_nil assigns(:entry)
97 assert_equal 'folder', assigns(:entry).name
98 end
99
92 def test_diff
100 def test_diff
93 get :diff, :id => 1, :rev => 3
101 get :diff, :id => 1, :rev => 3
94 assert_response :success
102 assert_response :success
General Comments 0
You need to be logged in to leave comments. Login now