@@ -47,7 +47,7 module Redmine | |||||
47 |
|
47 | |||
48 | # Get info about the svn repository |
|
48 | # Get info about the svn repository | |
49 | def info |
|
49 | def info | |
50 |
cmd = "#{SVN_BIN} info --xml #{target |
|
50 | cmd = "#{SVN_BIN} info --xml #{target}" | |
51 | cmd << credentials_string |
|
51 | cmd << credentials_string | |
52 | info = nil |
|
52 | info = nil | |
53 | shellout(cmd) do |io| |
|
53 | shellout(cmd) do |io| | |
@@ -77,7 +77,7 module Redmine | |||||
77 | path ||= '' |
|
77 | path ||= '' | |
78 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" |
|
78 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" | |
79 | entries = Entries.new |
|
79 | entries = Entries.new | |
80 |
cmd = "#{SVN_BIN} list --xml #{target( |
|
80 | cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}" | |
81 | cmd << credentials_string |
|
81 | cmd << credentials_string | |
82 | shellout(cmd) do |io| |
|
82 | shellout(cmd) do |io| | |
83 | output = io.read |
|
83 | output = io.read | |
@@ -116,7 +116,7 module Redmine | |||||
116 | return nil unless self.class.client_version_above?([1, 5, 0]) |
|
116 | return nil unless self.class.client_version_above?([1, 5, 0]) | |
117 |
|
117 | |||
118 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" |
|
118 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" | |
119 |
cmd = "#{SVN_BIN} proplist --verbose --xml #{target( |
|
119 | cmd = "#{SVN_BIN} proplist --verbose --xml #{target(path)}@#{identifier}" | |
120 | cmd << credentials_string |
|
120 | cmd << credentials_string | |
121 | properties = {} |
|
121 | properties = {} | |
122 | shellout(cmd) do |io| |
|
122 | shellout(cmd) do |io| | |
@@ -142,7 +142,7 module Redmine | |||||
142 | cmd << credentials_string |
|
142 | cmd << credentials_string | |
143 | cmd << " --verbose " if options[:with_paths] |
|
143 | cmd << " --verbose " if options[:with_paths] | |
144 | cmd << " --limit #{options[:limit].to_i}" if options[:limit] |
|
144 | cmd << " --limit #{options[:limit].to_i}" if options[:limit] | |
145 |
cmd << ' ' + target( |
|
145 | cmd << ' ' + target(path) | |
146 | shellout(cmd) do |io| |
|
146 | shellout(cmd) do |io| | |
147 | output = io.read |
|
147 | output = io.read | |
148 | begin |
|
148 | begin | |
@@ -180,7 +180,7 module Redmine | |||||
180 | cmd = "#{SVN_BIN} diff -r " |
|
180 | cmd = "#{SVN_BIN} diff -r " | |
181 | cmd << "#{identifier_to}:" |
|
181 | cmd << "#{identifier_to}:" | |
182 | cmd << "#{identifier_from}" |
|
182 | cmd << "#{identifier_from}" | |
183 |
cmd << " #{target( |
|
183 | cmd << " #{target(path)}@#{identifier_from}" | |
184 | cmd << credentials_string |
|
184 | cmd << credentials_string | |
185 | diff = [] |
|
185 | diff = [] | |
186 | shellout(cmd) do |io| |
|
186 | shellout(cmd) do |io| | |
@@ -194,7 +194,7 module Redmine | |||||
194 |
|
194 | |||
195 | def cat(path, identifier=nil) |
|
195 | def cat(path, identifier=nil) | |
196 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" |
|
196 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" | |
197 |
cmd = "#{SVN_BIN} cat #{target( |
|
197 | cmd = "#{SVN_BIN} cat #{target(path)}@#{identifier}" | |
198 | cmd << credentials_string |
|
198 | cmd << credentials_string | |
199 | cat = nil |
|
199 | cat = nil | |
200 | shellout(cmd) do |io| |
|
200 | shellout(cmd) do |io| | |
@@ -207,7 +207,7 module Redmine | |||||
207 |
|
207 | |||
208 | def annotate(path, identifier=nil) |
|
208 | def annotate(path, identifier=nil) | |
209 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" |
|
209 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" | |
210 |
cmd = "#{SVN_BIN} blame #{target( |
|
210 | cmd = "#{SVN_BIN} blame #{target(path)}@#{identifier}" | |
211 | cmd << credentials_string |
|
211 | cmd << credentials_string | |
212 | blame = Annotate.new |
|
212 | blame = Annotate.new | |
213 | shellout(cmd) do |io| |
|
213 | shellout(cmd) do |io| | |
@@ -243,6 +243,13 module Redmine | |||||
243 | end |
|
243 | end | |
244 | end |
|
244 | end | |
245 | end |
|
245 | end | |
|
246 | ||||
|
247 | def target(path = '') | |||
|
248 | base = path.match(/^\//) ? root_url : url | |||
|
249 | uri = "#{base}/#{path}" | |||
|
250 | uri = URI.escape(URI.escape(uri), '[]') | |||
|
251 | shell_quote(uri.gsub(/[?<>\*]/, '')) | |||
|
252 | end | |||
246 | end |
|
253 | end | |
247 | end |
|
254 | end | |
248 | end |
|
255 | end |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -57,7 +57,7 class RepositoriesSubversionControllerTest < ActionController::TestCase | |||||
57 | assert_response :success |
|
57 | assert_response :success | |
58 | assert_template 'show' |
|
58 | assert_template 'show' | |
59 | assert_not_nil assigns(:entries) |
|
59 | assert_not_nil assigns(:entries) | |
60 | assert_equal ['folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name) |
|
60 | assert_equal ['[folder_with_brackets]', 'folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name) | |
61 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} |
|
61 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} | |
62 | assert_equal 'file', entry.kind |
|
62 | assert_equal 'file', entry.kind | |
63 | assert_equal 'subversion_test/helloworld.c', entry.path |
|
63 | assert_equal 'subversion_test/helloworld.c', entry.path |
@@ -18,7 +18,7 | |||||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 |
|
19 | |||
20 | class RepositorySubversionTest < ActiveSupport::TestCase |
|
20 | class RepositorySubversionTest < ActiveSupport::TestCase | |
21 | fixtures :projects |
|
21 | fixtures :projects, :repositories | |
22 |
|
22 | |||
23 | def setup |
|
23 | def setup | |
24 | @project = Project.find(1) |
|
24 | @project = Project.find(1) | |
@@ -30,8 +30,8 class RepositorySubversionTest < ActiveSupport::TestCase | |||||
30 | @repository.fetch_changesets |
|
30 | @repository.fetch_changesets | |
31 | @repository.reload |
|
31 | @repository.reload | |
32 |
|
32 | |||
33 |
assert_equal 1 |
|
33 | assert_equal 11, @repository.changesets.count | |
34 |
assert_equal |
|
34 | assert_equal 20, @repository.changes.count | |
35 | assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments |
|
35 | assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments | |
36 | end |
|
36 | end | |
37 |
|
37 | |||
@@ -43,7 +43,7 class RepositorySubversionTest < ActiveSupport::TestCase | |||||
43 | assert_equal 5, @repository.changesets.count |
|
43 | assert_equal 5, @repository.changesets.count | |
44 |
|
44 | |||
45 | @repository.fetch_changesets |
|
45 | @repository.fetch_changesets | |
46 |
assert_equal 1 |
|
46 | assert_equal 11, @repository.changesets.count | |
47 | end |
|
47 | end | |
48 |
|
48 | |||
49 | def test_latest_changesets |
|
49 | def test_latest_changesets | |
@@ -62,6 +62,32 class RepositorySubversionTest < ActiveSupport::TestCase | |||||
62 | changesets = @repository.latest_changesets('subversion_test/folder', 8) |
|
62 | changesets = @repository.latest_changesets('subversion_test/folder', 8) | |
63 | assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision) |
|
63 | assert_equal ["7", "6", "5", "2"], changesets.collect(&:revision) | |
64 | end |
|
64 | end | |
|
65 | ||||
|
66 | def test_directory_listing_with_square_brackets_in_path | |||
|
67 | @repository.fetch_changesets | |||
|
68 | @repository.reload | |||
|
69 | ||||
|
70 | entries = @repository.entries('subversion_test/[folder_with_brackets]') | |||
|
71 | assert_not_nil entries, 'Expect to find entries in folder_with_brackets' | |||
|
72 | assert_equal 1, entries.size, 'Expect one entry in folder_with_brackets' | |||
|
73 | assert_equal 'README.txt', entries.first.name | |||
|
74 | end | |||
|
75 | ||||
|
76 | def test_directory_listing_with_square_brackets_in_base | |||
|
77 | @project = Project.find(1) | |||
|
78 | @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}/subversion_test/[folder_with_brackets]") | |||
|
79 | ||||
|
80 | @repository.fetch_changesets | |||
|
81 | @repository.reload | |||
|
82 | ||||
|
83 | assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision' | |||
|
84 | assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add' | |||
|
85 | ||||
|
86 | entries = @repository.entries('') | |||
|
87 | assert_not_nil entries, 'Expect to find entries' | |||
|
88 | assert_equal 1, entries.size, 'Expect a single entry' | |||
|
89 | assert_equal 'README.txt', entries.first.name | |||
|
90 | end | |||
65 | else |
|
91 | else | |
66 | puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" |
|
92 | puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" | |
67 | def test_fake; assert true end |
|
93 | def test_fake; assert true end |
General Comments 0
You need to be logged in to leave comments.
Login now