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)
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?
# 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
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)
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
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)
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 "
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
return nil\r
end\r
\r
- # Returns the entry identified by path and revision identifier\r
- # or nil if entry doesn't exist in the repository\r
- def entry(path=nil, identifier=nil)\r
- e = entries(path, identifier)\r
- e ? e.first : nil\r
- end\r
- \r
# Returns an Entries collection\r
# or nil if the given path doesn't exist in the repository\r
def entries(path=nil, identifier=nil)\r
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
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
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'
# 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
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