]> source.dussan.org Git - redmine.git/commitdiff
Fixes platform determination under JRuby (#1804).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 25 Aug 2008 11:01:37 +0000 (11:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 25 Aug 2008 11:01:37 +0000 (11:01 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1753 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/platform.rb [new file with mode: 0644]
lib/redmine/scm/adapters/abstract_adapter.rb
test/functional/repositories_cvs_controller_test.rb
test/functional/repositories_git_controller_test.rb
test/unit/repository_cvs_test.rb
test/unit/repository_git_test.rb

diff --git a/lib/redmine/platform.rb b/lib/redmine/platform.rb
new file mode 100644 (file)
index 0000000..f41b92f
--- /dev/null
@@ -0,0 +1,26 @@
+# Redmine - project management software
+# Copyright (C) 2006-2008  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+module Redmine
+  module Platform
+    class << self
+      def mswin?
+        (RUBY_PLATFORM =~ /(:?mswin|mingw)/) || (RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i)
+      end
+    end
+  end
+end
index c48ed20689187bd9f3f2ff74f4140c97f28d19a5..553b699634f80cfc51526dbf592ecbdb1480e4f6 100644 (file)
@@ -138,7 +138,7 @@ module Redmine
          end
         
         def shell_quote(str)
-          if RUBY_PLATFORM =~ /mswin/
+          if Redmine::Platform.mswin?
             '"' + str.gsub(/"/, '\\"') + '"'
           else
             "'" + str.gsub(/'/, "'\"'\"'") + "'"
@@ -186,7 +186,7 @@ module Redmine
         
         # Hides username/password in a given command
         def self.hide_credential(cmd)
-          q = (RUBY_PLATFORM =~ /mswin/ ? '"' : "'")
+          q = (Redmine::Platform.mswin? ? '"' : "'")
           cmd.to_s.gsub(/(\-\-(password|username))\s+(#{q}[^#{q}]+#{q}|[^#{q}]\S+)/, '\\1 xxxx')
         end
         
index 254fbc69c7fe441a3af3a767bfac37e6cb29e06f..2207d6ab6605e3614068dc974d7a1bf4de77c031 100644 (file)
@@ -25,7 +25,7 @@ class RepositoriesCvsControllerTest < Test::Unit::TestCase
 
   # No '..' in the repository path
   REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
-  REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
+  REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
   # CVS module
   MODULE_NAME = 'test'
   
index 339e22897e9faa14b185c29da5c015ead2b40cd8..201a506777e439310c24aef089e51be0a6543a30 100644 (file)
@@ -26,7 +26,7 @@ class RepositoriesGitControllerTest < Test::Unit::TestCase
 
   # No '..' in the repository path
   REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
-  REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
+  REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
 
   def setup
     @controller = RepositoriesController.new
index b14d9d96476c6be0806ab5964e4719465bc8bbe1..6615f73bfc1e120c019f86e0d6ec3299c147c8ed 100644 (file)
@@ -22,7 +22,7 @@ class RepositoryCvsTest < Test::Unit::TestCase
   
   # No '..' in the repository path
   REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
-  REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
+  REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
   # CVS module
   MODULE_NAME = 'test'
   
index c7bd84a6e9b77731902e353624d2d7a50f3f26a0..8a6f1ddd01eeaf4711d37dfa7cf731928e604125 100644 (file)
@@ -22,7 +22,7 @@ class RepositoryGitTest < Test::Unit::TestCase
   
   # No '..' in the repository path
   REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
-  REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
+  REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
   
   def setup
     @project = Project.find(1)