summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-02-14 08:45:34 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-02-14 08:45:34 +0000
commitcc4e8fe0d62387a0e015a5f22b451508c7d71e93 (patch)
treed579c750ad1477e406464c9b4f4a1c62d759cc4f /app/models
parent8b98c05879a278cd86fa83c73e5852cad3df4826 (diff)
downloadredmine-cc4e8fe0d62387a0e015a5f22b451508c7d71e93.tar.gz
redmine-cc4e8fe0d62387a0e015a5f22b451508c7d71e93.zip
scm: add scm command and version methods at repository models (#4273).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4822 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/repository.rb24
-rw-r--r--app/models/repository/bazaar.rb6
-rw-r--r--app/models/repository/cvs.rb6
-rw-r--r--app/models/repository/darcs.rb6
-rw-r--r--app/models/repository/filesystem.rb6
-rw-r--r--app/models/repository/git.rb4
-rw-r--r--app/models/repository/mercurial.rb2
-rw-r--r--app/models/repository/subversion.rb4
8 files changed, 39 insertions, 19 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 3d463b82f..1fbcf5f56 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -37,6 +37,10 @@ class Repository < ActiveRecord::Base
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
end
+ def scm_adapter
+ self.class.scm_adapter_class
+ end
+
def scm
@scm ||= self.scm_adapter.new url, root_url, login, password
update_attribute(:root_url, @scm.root_url) if root_url.blank?
@@ -46,7 +50,7 @@ class Repository < ActiveRecord::Base
def scm_name
self.class.scm_name
end
-
+
def supports_cat?
scm.supports_cat?
end
@@ -204,7 +208,23 @@ class Repository < ActiveRecord::Base
rescue
nil
end
-
+
+ def self.scm_adapter_class
+ nil
+ end
+
+ def self.scm_command
+ self.scm_adapter_class.nil? ? "" : self.scm_adapter_class.client_command
+ end
+
+ def self.scm_version_string
+ self.scm_adapter_class.nil? ? "" : self.scm_adapter_class.client_version_string
+ end
+
+ def self.scm_available
+ self.scm_adapter_class.nil? ? false : self.scm_adapter_class.client_available
+ end
+
private
def before_save
diff --git a/app/models/repository/bazaar.rb b/app/models/repository/bazaar.rb
index ec953bd45..9d7977e7e 100644
--- a/app/models/repository/bazaar.rb
+++ b/app/models/repository/bazaar.rb
@@ -21,14 +21,14 @@ class Repository::Bazaar < Repository
attr_protected :root_url
validates_presence_of :url
- def scm_adapter
+ def self.scm_adapter_class
Redmine::Scm::Adapters::BazaarAdapter
end
-
+
def self.scm_name
'Bazaar'
end
-
+
def entries(path=nil, identifier=nil)
entries = scm.entries(path, identifier)
if entries
diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb
index dbbb4694f..c0cac5cdc 100644
--- a/app/models/repository/cvs.rb
+++ b/app/models/repository/cvs.rb
@@ -21,14 +21,14 @@ require 'digest/sha1'
class Repository::Cvs < Repository
validates_presence_of :url, :root_url
- def scm_adapter
+ def self.scm_adapter_class
Redmine::Scm::Adapters::CvsAdapter
end
-
+
def self.scm_name
'CVS'
end
-
+
def entry(path=nil, identifier=nil)
rev = identifier.nil? ? nil : changesets.find_by_revision(identifier)
scm.entry(path, rev.nil? ? nil : rev.committed_on)
diff --git a/app/models/repository/darcs.rb b/app/models/repository/darcs.rb
index 43fb02946..dc3f0cee0 100644
--- a/app/models/repository/darcs.rb
+++ b/app/models/repository/darcs.rb
@@ -20,14 +20,14 @@ require 'redmine/scm/adapters/darcs_adapter'
class Repository::Darcs < Repository
validates_presence_of :url
- def scm_adapter
+ def self.scm_adapter_class
Redmine::Scm::Adapters::DarcsAdapter
end
-
+
def self.scm_name
'Darcs'
end
-
+
def entry(path=nil, identifier=nil)
patch = identifier.nil? ? nil : changesets.find_by_revision(identifier)
scm.entry(path, patch.nil? ? nil : patch.scmid)
diff --git a/app/models/repository/filesystem.rb b/app/models/repository/filesystem.rb
index da096cc09..4be6b5289 100644
--- a/app/models/repository/filesystem.rb
+++ b/app/models/repository/filesystem.rb
@@ -24,14 +24,14 @@ class Repository::Filesystem < Repository
attr_protected :root_url
validates_presence_of :url
- def scm_adapter
+ def self.scm_adapter_class
Redmine::Scm::Adapters::FilesystemAdapter
end
-
+
def self.scm_name
'Filesystem'
end
-
+
def entries(path=nil, identifier=nil)
scm.entries(path, identifier)
end
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index 9349f3c11..26cb84db9 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -21,10 +21,10 @@ class Repository::Git < Repository
attr_protected :root_url
validates_presence_of :url
- def scm_adapter
+ def self.scm_adapter_class
Redmine::Scm::Adapters::GitAdapter
end
-
+
def self.scm_name
'Git'
end
diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb
index 102c6dda8..557b9a4dc 100644
--- a/app/models/repository/mercurial.rb
+++ b/app/models/repository/mercurial.rb
@@ -24,7 +24,7 @@ class Repository::Mercurial < Repository
attr_protected :root_url
validates_presence_of :url
- def scm_adapter
+ def self.scm_adapter_class
Redmine::Scm::Adapters::MercurialAdapter
end
diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb
index 091d14130..059369298 100644
--- a/app/models/repository/subversion.rb
+++ b/app/models/repository/subversion.rb
@@ -22,10 +22,10 @@ class Repository::Subversion < Repository
validates_presence_of :url
validates_format_of :url, :with => /^(http|https|svn(\+[^\s:\/\\]+)?|file):\/\/.+/i
- def scm_adapter
+ def self.scm_adapter_class
Redmine::Scm::Adapters::SubversionAdapter
end
-
+
def self.scm_name
'Subversion'
end