@@ -65,7 +65,8 class RepositoriesController < ApplicationController | |||
|
65 | 65 | if request.xhr? |
|
66 | 66 | @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) |
|
67 | 67 | else |
|
68 | show_error_not_found unless @entries | |
|
68 | show_error_not_found and return unless @entries | |
|
69 | render :action => 'browse' | |
|
69 | 70 | end |
|
70 | 71 | rescue Redmine::Scm::Adapters::CommandFailed => e |
|
71 | 72 | show_error_command_failed(e.message) |
@@ -95,6 +96,12 class RepositoriesController < ApplicationController | |||
|
95 | 96 | end |
|
96 | 97 | |
|
97 | 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 | 105 | @content = @repository.scm.cat(@path, @rev) |
|
99 | 106 | show_error_not_found and return unless @content |
|
100 | 107 | if 'raw' == params[:format] || @content.is_binary_data? |
@@ -59,8 +59,17 module Redmine | |||
|
59 | 59 | # Returns the entry identified by path and revision identifier |
|
60 | 60 | # or nil if entry doesn't exist in the repository |
|
61 | 61 | def entry(path=nil, identifier=nil) |
|
62 | e = entries(path, identifier) | |
|
63 | e ? e.first : nil | |
|
62 | parts = path.to_s.split(%r{[\/\\]}).select {|n| !n.blank?} | |
|
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 | 73 | end |
|
65 | 74 | |
|
66 | 75 | # Returns an Entries collection |
@@ -44,18 +44,6 module Redmine | |||
|
44 | 44 | return nil |
|
45 | 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 | 47 | # Returns an Entries collection |
|
60 | 48 | # or nil if the given path doesn't exist in the repository |
|
61 | 49 | def entries(path=nil, identifier=nil) |
@@ -55,15 +55,6 module Redmine | |||
|
55 | 55 | def get_previous_revision(revision) |
|
56 | 56 | CvsRevisionHelper.new(revision).prevRev |
|
57 | 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 | 59 | # Returns an Entries collection |
|
69 | 60 | # or nil if the given path doesn't exist in the repository |
@@ -40,13 +40,6 module Redmine | |||
|
40 | 40 | rev ? Info.new({:root_url => @url, :lastrev => rev.last}) : nil |
|
41 | 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 | 43 | # Returns an Entries collection |
|
51 | 44 | # or nil if the given path doesn't exist in the repository |
|
52 | 45 | def entries(path=nil, identifier=nil) |
@@ -132,14 +132,6 module Redmine | |||
|
132 | 132 | entries.sort_by_name |
|
133 | 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 | 135 | def revisions(path, identifier_from, identifier_to, options={}) |
|
144 | 136 | revisions = Revisions.new |
|
145 | 137 | cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw " |
@@ -59,14 +59,6 module Redmine | |||
|
59 | 59 | return nil if $? && $?.exitstatus != 0 |
|
60 | 60 | entries.sort_by_name |
|
61 | 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 | 63 | def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) |
|
72 | 64 | revisions = Revisions.new |
@@ -51,13 +51,6 module Redmine | |||
|
51 | 51 | return nil |
|
52 | 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 | 54 | # Returns an Entries collection |
|
62 | 55 | # or nil if the given path doesn't exist in the repository |
|
63 | 56 | def entries(path=nil, identifier=nil) |
@@ -99,6 +99,14 class RepositoriesBazaarControllerTest < Test::Unit::TestCase | |||
|
99 | 99 | assert @response.body.include?('Show help message') |
|
100 | 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 | 110 | def test_diff |
|
103 | 111 | # Full diff of changeset 3 |
|
104 | 112 | get :diff, :id => 3, :rev => 3 |
@@ -101,6 +101,14 class RepositoriesCvsControllerTest < Test::Unit::TestCase | |||
|
101 | 101 | get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' |
|
102 | 102 | assert_response :success |
|
103 | 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 | 113 | def test_diff |
|
106 | 114 | Project.find(1).repository.fetch_changesets |
@@ -101,6 +101,14 class RepositoriesGitControllerTest < Test::Unit::TestCase | |||
|
101 | 101 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
102 | 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 | 112 | def test_diff |
|
105 | 113 | # Full diff of changeset 2f9c0091 |
|
106 | 114 | get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
@@ -99,7 +99,15 class RepositoriesMercurialControllerTest < Test::Unit::TestCase | |||
|
99 | 99 | # File content |
|
100 | 100 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
101 | 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 | 111 | def test_diff |
|
104 | 112 | # Full diff of changeset 4 |
|
105 | 113 | get :diff, :id => 3, :rev => 4 |
@@ -89,6 +89,14 class RepositoriesSubversionControllerTest < Test::Unit::TestCase | |||
|
89 | 89 | assert_response :success |
|
90 | 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 | 100 | def test_diff |
|
93 | 101 | get :diff, :id => 1, :rev => 3 |
|
94 | 102 | assert_response :success |
General Comments 0
You need to be logged in to leave comments.
Login now