summaryrefslogtreecommitdiffstats
path: root/app/models/repository.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-02-19 01:11:48 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-02-19 01:11:48 +0000
commita092f5e0b9af97e9bdd54946a16585c914159d6e (patch)
treeb2441222cd414d05468e6ae55d4365e47e525588 /app/models/repository.rb
parent3861214ccc3e1b7fdf80649056f361d4cc22f67c (diff)
downloadredmine-a092f5e0b9af97e9bdd54946a16585c914159d6e.tar.gz
redmine-a092f5e0b9af97e9bdd54946a16585c914159d6e.zip
scm: catch exception of getting command and version in model (#4273).
If command does not exist, Windows raises exception in shellout(). Linux does not raise exception. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4882 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r--app/models/repository.rb30
1 files changed, 24 insertions, 6 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 4ddc73432..d1e3d8b2f 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -177,7 +177,7 @@ class Repository < ActiveRecord::Base
user
end
end
-
+
# Fetches new changesets for all repositories of active projects
# Can be called periodically by an external script
# eg. ruby script/runner "Repository.fetch_changesets"
@@ -187,12 +187,12 @@ class Repository < ActiveRecord::Base
begin
project.repository.fetch_changesets
rescue Redmine::Scm::Adapters::CommandFailed => e
- logger.error "Repository: error during fetching changesets: #{e.message}"
+ logger.error "scm: error during fetching changesets: #{e.message}"
end
end
end
end
-
+
# scan changeset comments to find related and fixed issues for all repositories
def self.scan_changesets_for_issue_ids
find(:all).each(&:scan_changesets_for_issue_ids)
@@ -218,15 +218,33 @@ class Repository < ActiveRecord::Base
end
def self.scm_command
- self.scm_adapter_class.nil? ? "" : self.scm_adapter_class.client_command
+ ret = ""
+ begin
+ ret = self.scm_adapter_class.client_command if self.scm_adapter_class
+ rescue Redmine::Scm::Adapters::CommandFailed => e
+ logger.error "scm: error during get command: #{e.message}"
+ end
+ ret
end
def self.scm_version_string
- self.scm_adapter_class.nil? ? "" : self.scm_adapter_class.client_version_string
+ ret = ""
+ begin
+ ret = self.scm_adapter_class.client_version_string if self.scm_adapter_class
+ rescue Redmine::Scm::Adapters::CommandFailed => e
+ logger.error "scm: error during get version string: #{e.message}"
+ end
+ ret
end
def self.scm_available
- self.scm_adapter_class.nil? ? false : self.scm_adapter_class.client_available
+ ret = false
+ begin
+ ret = self.scm_adapter_class.client_available if self.scm_adapter_class
+ rescue Redmine::Scm::Adapters::CommandFailed => e
+ logger.error "scm: error during get scm available: #{e.message}"
+ end
+ ret
end
private