# Checks if the SCM is enabled when creating a repository
validate_on_create { |r| r.errors.add(:type, :invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
-
+
# Removes leading and trailing whitespace
def url=(arg)
write_attribute(:url, arg ? arg.to_s.strip : nil)
end
-
+
# Removes leading and trailing whitespace
def root_url=(arg)
write_attribute(:root_url, arg ? arg.to_s.strip : nil)
end
def scm
- @scm ||= self.scm_adapter.new url, root_url, login, password
+ @scm ||= self.scm_adapter.new(url, root_url,
+ login, password, path_encoding)
update_attribute(:root_url, @scm.root_url) if root_url.blank?
@scm
end
-
+
def scm_name
self.class.scm_name
end
end
private
-
+
def before_save
# Strips url and root_url
url.strip!
def client_version
[]
end
-
+
# Returns the version string of the scm client
# Eg: '1.5.0' or 'Unknown version' if unknown
def client_version_string
v = client_version || 'Unknown version'
v.is_a?(Array) ? v.join('.') : v.to_s
end
-
+
# Returns true if the current client version is above
# or equals the given one
# If option is :unknown is set to true, it will return
end
end
- def initialize(url, root_url=nil, login=nil, password=nil)
+ def initialize(url, root_url=nil, login=nil, password=nil,
+ path_encoding=nil)
@url = url
@login = login if login && !login.empty?
@password = (password || "") if @login
@root_url = root_url.blank? ? retrieve_root_url : root_url
end
-
+
def adapter_name
'Abstract'
end
-
+
def supports_cat?
true
end
def supports_annotate?
respond_to?('annotate')
end
-
+
def root_url
@root_url
end
-
+
def url
@url
end
# root_url -> the good old, sometimes damned, CVSROOT
# login -> unnecessary
# password -> unnecessary too
- def initialize(url, root_url=nil, login=nil, password=nil)
+ def initialize(url, root_url=nil, login=nil, password=nil,
+ path_encoding=nil)
@url = url
@login = login if login && !login.empty?
@password = (password || "") if @login
end
end
- def initialize(url, root_url=nil, login=nil, password=nil)
+ def initialize(url, root_url=nil, login=nil, password=nil,
+ path_encoding=nil)
@url = url
@root_url = url
end
end
end
- def initialize(url, root_url=nil, login=nil, password=nil)
+ def initialize(url, root_url=nil, login=nil, password=nil,
+ path_encoding=nil)
@url = with_trailling_slash(url)
- @path_encoding = 'UTF-8'
+ @path_encoding = path_encoding || 'UTF-8'
end
def format_path_ends(path, leading=true, trailling=true)
end
end
- def initialize(url, root_url=nil, login=nil, password=nil)
+ def initialize(url, root_url=nil, login=nil, password=nil, path_encoding=nil)
super
- @path_encoding = 'UTF-8'
+ @path_encoding = path_encoding || 'UTF-8'
end
def info