@@ -81,6 +81,14 module Redmine | |||||
81 | path ||= '' |
|
81 | path ||= '' | |
82 | (path[0,1]!="/") ? "/#{path}" : path |
|
82 | (path[0,1]!="/") ? "/#{path}" : path | |
83 | end |
|
83 | end | |
|
84 | ||||
|
85 | def shell_quote(str) | |||
|
86 | if RUBY_PLATFORM =~ /mswin/ | |||
|
87 | '"' + str.gsub(/"/, '\\"') + '"' | |||
|
88 | else | |||
|
89 | "'" + str.gsub(/'/, "'\"'\"'") + "'" | |||
|
90 | end | |||
|
91 | end | |||
84 |
|
92 | |||
85 | private |
|
93 | private | |
86 | def retrieve_root_url |
|
94 | def retrieve_root_url |
@@ -29,7 +29,7 module Redmine | |||||
29 | # Get info about the svn repository |
|
29 | # Get info about the svn repository | |
30 | def info |
|
30 | def info | |
31 | cmd = "#{SVN_BIN} info --xml #{target('')}" |
|
31 | cmd = "#{SVN_BIN} info --xml #{target('')}" | |
32 | cmd << " --username #{@login} --password #{@password}" if @login |
|
32 | cmd << credentials_string | |
33 | info = nil |
|
33 | info = nil | |
34 | shellout(cmd) do |io| |
|
34 | shellout(cmd) do |io| | |
35 | begin |
|
35 | begin | |
@@ -65,7 +65,7 module Redmine | |||||
65 | identifier = 'HEAD' unless identifier and identifier > 0 |
|
65 | identifier = 'HEAD' unless identifier and identifier > 0 | |
66 | entries = Entries.new |
|
66 | entries = Entries.new | |
67 | cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}" |
|
67 | cmd = "#{SVN_BIN} list --xml #{target(path)}@#{identifier}" | |
68 | cmd << " --username #{@login} --password #{@password}" if @login |
|
68 | cmd << credentials_string | |
69 | cmd << " 2>&1" |
|
69 | cmd << " 2>&1" | |
70 | shellout(cmd) do |io| |
|
70 | shellout(cmd) do |io| | |
71 | output = io.read |
|
71 | output = io.read | |
@@ -101,7 +101,7 module Redmine | |||||
101 | identifier_to = 1 unless identifier_to and identifier_to.to_i > 0 |
|
101 | identifier_to = 1 unless identifier_to and identifier_to.to_i > 0 | |
102 | revisions = Revisions.new |
|
102 | revisions = Revisions.new | |
103 | cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}" |
|
103 | cmd = "#{SVN_BIN} log --xml -r #{identifier_from}:#{identifier_to}" | |
104 | cmd << " --username #{@login} --password #{@password}" if @login |
|
104 | cmd << credentials_string | |
105 | cmd << " --verbose " if options[:with_paths] |
|
105 | cmd << " --verbose " if options[:with_paths] | |
106 | cmd << target(path) |
|
106 | cmd << target(path) | |
107 | shellout(cmd) do |io| |
|
107 | shellout(cmd) do |io| | |
@@ -145,7 +145,7 module Redmine | |||||
145 | cmd << "#{identifier_to}:" |
|
145 | cmd << "#{identifier_to}:" | |
146 | cmd << "#{identifier_from}" |
|
146 | cmd << "#{identifier_from}" | |
147 | cmd << "#{target(path)}@#{identifier_from}" |
|
147 | cmd << "#{target(path)}@#{identifier_from}" | |
148 | cmd << " --username #{@login} --password #{@password}" if @login |
|
148 | cmd << credentials_string | |
149 | diff = [] |
|
149 | diff = [] | |
150 | shellout(cmd) do |io| |
|
150 | shellout(cmd) do |io| | |
151 | io.each_line do |line| |
|
151 | io.each_line do |line| | |
@@ -161,7 +161,7 module Redmine | |||||
161 | def cat(path, identifier=nil) |
|
161 | def cat(path, identifier=nil) | |
162 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" |
|
162 | identifier = (identifier and identifier.to_i > 0) ? identifier.to_i : "HEAD" | |
163 | cmd = "#{SVN_BIN} cat #{target(path)}@#{identifier}" |
|
163 | cmd = "#{SVN_BIN} cat #{target(path)}@#{identifier}" | |
164 | cmd << " --username #{@login} --password #{@password}" if @login |
|
164 | cmd << credentials_string | |
165 | cat = nil |
|
165 | cat = nil | |
166 | shellout(cmd) do |io| |
|
166 | shellout(cmd) do |io| | |
167 | io.binmode |
|
167 | io.binmode | |
@@ -172,6 +172,15 module Redmine | |||||
172 | rescue Errno::ENOENT => e |
|
172 | rescue Errno::ENOENT => e | |
173 | raise CommandFailed |
|
173 | raise CommandFailed | |
174 | end |
|
174 | end | |
|
175 | ||||
|
176 | private | |||
|
177 | ||||
|
178 | def credentials_string | |||
|
179 | str = '' | |||
|
180 | str << " --username #{shell_quote(@login)}" unless @login.blank? | |||
|
181 | str << " --password #{shell_quote(@password)}" unless @login.blank? || @password.blank? | |||
|
182 | str | |||
|
183 | end | |||
175 | end |
|
184 | end | |
176 | end |
|
185 | end | |
177 | end |
|
186 | end |
General Comments 0
You need to be logged in to leave comments.
Login now