]> source.dussan.org Git - redmine.git/commitdiff
Converted the REDMINE_SUPPORTED_SCM constant to a class
authorEric Davis <edavis@littlestreamsoftware.com>
Tue, 16 Feb 2010 22:41:59 +0000 (22:41 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Tue, 16 Feb 2010 22:41:59 +0000 (22:41 +0000)
Now SCMs can be added or removed using a simple API, instead of being
hardcoded:

  Redmine::Scm::Base.add('ScmName')
  Redmine::Scm::Base.delete('ScmName')

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3440 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb
app/helpers/repositories_helper.rb
app/views/settings/_repositories.rhtml
lib/redmine.rb
lib/redmine/scm/base.rb [new file with mode: 0644]

index 74f4aef273cc2c78e6d4cb6edd5ca4252df71b65..4cc6713966c559ab50bd0af0c206132d987bb9c0 100644 (file)
@@ -46,7 +46,7 @@ class ApplicationController < ActionController::Base
   include Redmine::MenuManager::MenuController
   helper Redmine::MenuManager::MenuHelper
   
-  REDMINE_SUPPORTED_SCM.each do |scm|
+  Redmine::Scm::Base.all.each do |scm|
     require_dependency "repository/#{scm.underscore}"
   end
 
index 0e0f94c79f8ce3b1455c4d5e337ebfc487d92f18..0c2a44809a6afd860c1723a57adeb66b2a7621f6 100644 (file)
@@ -126,7 +126,7 @@ module RepositoriesHelper
   
   def scm_select_tag(repository)
     scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
-    REDMINE_SUPPORTED_SCM.each do |scm|
+    Redmine::Scm::Base.all.each do |scm|
       scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm)
     end
     
index 581ebf5fd50c8bff1b30ea42c7bcc1ecf37c2047..198b83289542524c5e0625081f577d2151402a04 100644 (file)
@@ -13,7 +13,7 @@
   <%= link_to_function l(:label_generate_key), "if ($('settings_sys_api_key').disabled == false) { $('settings_sys_api_key').value = randomKey(20) }" %>
 </p>
 
-<p><%= setting_multiselect(:enabled_scm, REDMINE_SUPPORTED_SCM) %></p>
+<p><%= setting_multiselect(:enabled_scm, Redmine::Scm::Base.all) %></p>
 
 <p><%= setting_text_field :repositories_encodings, :size => 60 %><br />
 <em><%= l(:text_comma_separated) %></em></p>
index 573692ff1ea9ea07970b4d1a766e888244924b36..d9a1f40639b5e134f7ef3a1859cb6d561c213f81 100644 (file)
@@ -7,6 +7,7 @@ require 'redmine/themes'
 require 'redmine/hook'
 require 'redmine/plugin'
 require 'redmine/wiki_formatting'
+require 'redmine/scm/base'
 
 begin
   require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick)
@@ -21,7 +22,13 @@ else
   FCSV = CSV
 end
 
-REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar Git Filesystem )
+Redmine::Scm::Base.add "Subversion"
+Redmine::Scm::Base.add "Darcs"
+Redmine::Scm::Base.add "Mercurial"
+Redmine::Scm::Base.add "Cvs"
+Redmine::Scm::Base.add "Bazaar"
+Redmine::Scm::Base.add "Git"
+Redmine::Scm::Base.add "Filesystem"
 
 # Permissions
 Redmine::AccessControl.map do |map|
diff --git a/lib/redmine/scm/base.rb b/lib/redmine/scm/base.rb
new file mode 100644 (file)
index 0000000..43e8a18
--- /dev/null
@@ -0,0 +1,23 @@
+module Redmine
+  module Scm
+    class Base
+      class << self
+
+        def all
+          @scms
+        end
+
+        # Add a new SCM adapter and repository
+        def add(scm_name)
+          @scms ||= []
+          @scms << scm_name
+        end
+
+        # Remove a SCM adapter from Redmine's list of supported scms
+        def delete(scm_name)
+          @scms.delete(scm_name)
+        end
+      end
+    end
+  end
+end