Index: init.rb =================================================================== --- init.rb (revision 4) +++ init.rb (working copy) @@ -%ld,%ld +%ld,%ld @@ require 'redmine' require 'dispatcher' -require_dependency 'svn' +require_dependency 'svn_config' RAILS_DEFAULT_LOGGER.info 'Starting Subversion Plugin for Redmine' Index: lib/repositories_helper_patch.rb =================================================================== --- lib/repositories_helper_patch.rb (revision 4) +++ lib/repositories_helper_patch.rb (working copy) @@ -%ld,%ld +%ld,%ld @@ def subversion_field_tags_with_add(form, repository) svntags = subversion_field_tags_without_add(form, repository) - if !@project.repository && Svn['path'].present? + if !@project.repository && SvnConfig['path'].present? add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';") svntags['
'] = ' ' + add + '
' svntags << hidden_field_tag(:operation, '', :id => 'repository_operation') unless params && params[:repository] - path = Svn['path'].dup + path = SvnConfig['path'].dup path.gsub!(/\\/, "/") if Redmine::Platform.mswin? svntags << javascript_tag("$('repository_url').value = 'file://#{path}/';") # FIXME: escape end @@ -%ld,%ld +%ld,%ld @@ end end + Index: lib/svn.rb =================================================================== --- lib/svn.rb (revision 4) +++ lib/svn.rb (working copy) @@ -%ld,%ld +%ld,%ld @@ -class Svn - - @@instance = nil - @@configs = {} - - def self.[](config) - if @@instance.nil? - @@instance = new - end - @@configs[config] - end - -protected - - def initialize - file = "#{RAILS_ROOT}/config/subversion.yml" - if File.file?(file) - config = YAML::load_file(file) - if config.is_a?(Hash) && config.has_key?(Rails.env) - @@configs = config[Rails.env] - end - end - end - -end Index: lib/repositories_controller_patch.rb =================================================================== --- lib/repositories_controller_patch.rb (revision 4) +++ lib/repositories_controller_patch.rb (working copy) @@ -%ld,%ld +%ld,%ld @@ if request.post? && @repository if params[:operation].present? && params[:operation] == 'add' if params[:repository] - path = Svn['path'].dup + path = SvnConfig['path'].dup path.gsub!(/\\/, "/") if Redmine::Platform.mswin? matches = Regexp.new("^file://#{Regexp.escape(path)}/([^/]+)/?$").match(params[:repository]['url']) if matches - repath = Redmine::Platform.mswin? ? "#{Svn['path']}\\#{matches[1]}" : "#{Svn['path']}/#{matches[1]}" + repath = Redmine::Platform.mswin? ? "#{SvnConfig['path']}\\#{matches[1]}" : "#{SvnConfig['path']}/#{matches[1]}" if File.directory?(repath) @repository.errors.add(:url, :already_exists) else - system(Svn['svnadmin'], 'create', repath) + system(SvnConfig['svnadmin'], 'create', repath) end else @repository.errors.add(:url, :should_be_of_format_local, :svn_path => path) @@ -%ld,%ld +%ld,%ld @@ end end + Index: lib/svn_config.rb =================================================================== --- lib/svn_config.rb (revision 0) +++ lib/svn_config.rb (revision 0) @@ -%ld,%ld +%ld,%ld @@ +class SvnConfig + + @@instance = nil + @@configs = {} + + def self.[](config) + if @@instance.nil? + @@instance = new + end + @@configs[config] + end + +protected + + def initialize + file = "#{RAILS_ROOT}/config/subversion.yml" + if File.file?(file) + config = YAML::load_file(file) + if config.is_a?(Hash) && config.has_key?(Rails.env) + @@configs = config[Rails.env] + end + end + end + +end +