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
This commit is contained in:
parent
8b98c05879
commit
cc4e8fe0d6
|
@ -37,6 +37,10 @@ class Repository < ActiveRecord::Base
|
||||||
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
|
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def scm_adapter
|
||||||
|
self.class.scm_adapter_class
|
||||||
|
end
|
||||||
|
|
||||||
def scm
|
def scm
|
||||||
@scm ||= self.scm_adapter.new url, root_url, login, password
|
@scm ||= self.scm_adapter.new url, root_url, login, password
|
||||||
update_attribute(:root_url, @scm.root_url) if root_url.blank?
|
update_attribute(:root_url, @scm.root_url) if root_url.blank?
|
||||||
|
@ -205,6 +209,22 @@ class Repository < ActiveRecord::Base
|
||||||
nil
|
nil
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def before_save
|
def before_save
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Repository::Bazaar < Repository
|
||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def scm_adapter
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::BazaarAdapter
|
Redmine::Scm::Adapters::BazaarAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ require 'digest/sha1'
|
||||||
class Repository::Cvs < Repository
|
class Repository::Cvs < Repository
|
||||||
validates_presence_of :url, :root_url
|
validates_presence_of :url, :root_url
|
||||||
|
|
||||||
def scm_adapter
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::CvsAdapter
|
Redmine::Scm::Adapters::CvsAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ require 'redmine/scm/adapters/darcs_adapter'
|
||||||
class Repository::Darcs < Repository
|
class Repository::Darcs < Repository
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def scm_adapter
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::DarcsAdapter
|
Redmine::Scm::Adapters::DarcsAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Repository::Filesystem < Repository
|
||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def scm_adapter
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::FilesystemAdapter
|
Redmine::Scm::Adapters::FilesystemAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Repository::Git < Repository
|
||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def scm_adapter
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::GitAdapter
|
Redmine::Scm::Adapters::GitAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Repository::Mercurial < Repository
|
||||||
attr_protected :root_url
|
attr_protected :root_url
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
|
|
||||||
def scm_adapter
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::MercurialAdapter
|
Redmine::Scm::Adapters::MercurialAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Repository::Subversion < Repository
|
||||||
validates_presence_of :url
|
validates_presence_of :url
|
||||||
validates_format_of :url, :with => /^(http|https|svn(\+[^\s:\/\\]+)?|file):\/\/.+/i
|
validates_format_of :url, :with => /^(http|https|svn(\+[^\s:\/\\]+)?|file):\/\/.+/i
|
||||||
|
|
||||||
def scm_adapter
|
def self.scm_adapter_class
|
||||||
Redmine::Scm::Adapters::SubversionAdapter
|
Redmine::Scm::Adapters::SubversionAdapter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue