Fixed: Links to repository directories don't work (#1119).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1365 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-04-27 10:12:15 +00:00
parent 6a3236daea
commit a73f68a185
13 changed files with 60 additions and 55 deletions

View File

@ -65,7 +65,8 @@ class RepositoriesController < ApplicationController
if request.xhr?
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
else
show_error_not_found unless @entries
show_error_not_found and return unless @entries
render :action => 'browse'
end
rescue Redmine::Scm::Adapters::CommandFailed => e
show_error_command_failed(e.message)
@ -95,6 +96,12 @@ class RepositoriesController < ApplicationController
end
def entry
@entry = @repository.scm.entry(@path, @rev)
show_error_not_found and return unless @entry
# If the entry is a dir, show the browser
browse and return if @entry.is_dir?
@content = @repository.scm.cat(@path, @rev)
show_error_not_found and return unless @content
if 'raw' == params[:format] || @content.is_binary_data?

View File

@ -59,8 +59,17 @@ module Redmine
# Returns the entry identified by path and revision identifier
# or nil if entry doesn't exist in the repository
def entry(path=nil, identifier=nil)
e = entries(path, identifier)
e ? e.first : nil
parts = path.to_s.split(%r{[\/\\]}).select {|n| !n.blank?}
search_path = parts[0..-2].join('/')
search_name = parts[-1]
if search_path.blank? && search_name.blank?
# Root entry
Entry.new(:path => '', :kind => 'dir')
else
# Search for the entry in the parent directory
es = entries(search_path, identifier)
es ? es.detect {|e| e.name == search_name} : nil
end
end
# Returns an Entries collection

View File

@ -44,18 +44,6 @@ module Redmine
return nil
end
# Returns the entry identified by path and revision identifier
# or nil if entry doesn't exist in the repository
def entry(path=nil, identifier=nil)
path ||= ''
parts = path.split(%r{[\/\\]}).select {|p| !p.blank?}
if parts.size > 0
parent = parts[0..-2].join('/')
entries = entries(parent, identifier)
entries ? entries.detect {|e| e.name == parts.last} : nil
end
end
# Returns an Entries collection
# or nil if the given path doesn't exist in the repository
def entries(path=nil, identifier=nil)

View File

@ -55,15 +55,6 @@ module Redmine
def get_previous_revision(revision)
CvsRevisionHelper.new(revision).prevRev
end
# Returns the entry identified by path and revision identifier
# or nil if entry doesn't exist in the repository
# this method returns all revisions from one single SCM-Entry
def entry(path=nil, identifier="HEAD")
e = entries(path, identifier)
logger.debug("<cvs-result> #{e.first.inspect}") if e
e ? e.first : nil
end
# Returns an Entries collection
# or nil if the given path doesn't exist in the repository

View File

@ -40,13 +40,6 @@ module Redmine
rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil
end
# Returns the entry identified by path and revision identifier
# or nil if entry doesn't exist in the repository
def entry(path=nil, identifier=nil)
e = entries(path, identifier)
e ? e.first : nil
end
# Returns an Entries collection
# or nil if the given path doesn't exist in the repository
def entries(path=nil, identifier=nil)

View File

@ -132,14 +132,6 @@ module Redmine
entries.sort_by_name
end
def entry(path=nil, identifier=nil)
path ||= ''
search_path = path.split('/')[0..-2].join('/')
entry_name = path.split('/').last
e = entries(search_path, identifier)
e ? e.detect{|entry| entry.name == entry_name} : nil
end
def revisions(path, identifier_from, identifier_to, options={})
revisions = Revisions.new
cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw "

View File

@ -59,14 +59,6 @@ module Redmine
return nil if $? && $?.exitstatus != 0
entries.sort_by_name
end
def entry(path=nil, identifier=nil)
path ||= ''
search_path = path.split('/')[0..-2].join('/')
entry_name = path.split('/').last
e = entries(search_path, identifier)
e ? e.detect{|entry| entry.name == entry_name} : nil
end
def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
revisions = Revisions.new

View File

@ -51,13 +51,6 @@ module Redmine
return nil
end
# Returns the entry identified by path and revision identifier
# or nil if entry doesn't exist in the repository
def entry(path=nil, identifier=nil)
e = entries(path, identifier)
e ? e.first : nil
end
# Returns an Entries collection
# or nil if the given path doesn't exist in the repository
def entries(path=nil, identifier=nil)

View File

@ -99,6 +99,14 @@ class RepositoriesBazaarControllerTest < Test::Unit::TestCase
assert @response.body.include?('Show help message')
end
def test_directory_entry
get :entry, :id => 3, :path => ['directory']
assert_response :success
assert_template 'browse'
assert_not_nil assigns(:entry)
assert_equal 'directory', assigns(:entry).name
end
def test_diff
# Full diff of changeset 3
get :diff, :id => 3, :rev => 3

View File

@ -101,6 +101,14 @@ class RepositoriesCvsControllerTest < Test::Unit::TestCase
get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
assert_response :success
end
def test_directory_entry
get :entry, :id => 1, :path => ['sources']
assert_response :success
assert_template 'browse'
assert_not_nil assigns(:entry)
assert_equal 'sources', assigns(:entry).name
end
def test_diff
Project.find(1).repository.fetch_changesets

View File

@ -101,6 +101,14 @@ class RepositoriesGitControllerTest < Test::Unit::TestCase
assert @response.body.include?('WITHOUT ANY WARRANTY')
end
def test_directory_entry
get :entry, :id => 3, :path => ['sources']
assert_response :success
assert_template 'browse'
assert_not_nil assigns(:entry)
assert_equal 'sources', assigns(:entry).name
end
def test_diff
# Full diff of changeset 2f9c0091
get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'

View File

@ -99,7 +99,15 @@ class RepositoriesMercurialControllerTest < Test::Unit::TestCase
# File content
assert @response.body.include?('WITHOUT ANY WARRANTY')
end
def test_directory_entry
get :entry, :id => 3, :path => ['sources']
assert_response :success
assert_template 'browse'
assert_not_nil assigns(:entry)
assert_equal 'sources', assigns(:entry).name
end
def test_diff
# Full diff of changeset 4
get :diff, :id => 3, :rev => 4

View File

@ -89,6 +89,14 @@ class RepositoriesSubversionControllerTest < Test::Unit::TestCase
assert_response :success
end
def test_directory_entry
get :entry, :id => 1, :path => ['subversion_test', 'folder']
assert_response :success
assert_template 'browse'
assert_not_nil assigns(:entry)
assert_equal 'folder', assigns(:entry).name
end
def test_diff
get :diff, :id => 1, :rev => 3
assert_response :success