summaryrefslogtreecommitdiffstats
path: root/app/models/repository.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-14 18:59:10 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-14 18:59:10 +0000
commit4957752d122388f15738b47b2872465da81a6d32 (patch)
treefdc44b7d16daef79348f0c48ae9e1374f54648f1 /app/models/repository.rb
parentb8b991a7dc3f253e1fbcb359e8280e7d0ff69b29 (diff)
downloadredmine-4957752d122388f15738b47b2872465da81a6d32.tar.gz
redmine-4957752d122388f15738b47b2872465da81a6d32.zip
Strip repository urls (closes #852).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1248 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 229c8dae4..8b1f8d0af 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -20,6 +20,16 @@ class Repository < ActiveRecord::Base
has_many :changesets, :dependent => :destroy, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
has_many :changes, :through => :changesets
+ # 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
update_attribute(:root_url, @scm.root_url) if root_url.blank?
@@ -88,4 +98,13 @@ class Repository < ActiveRecord::Base
rescue
nil
end
+
+ private
+
+ def before_save
+ # Strips url and root_url
+ url.strip!
+ root_url.strip!
+ true
+ end
end