summaryrefslogtreecommitdiffstats
path: root/extra/svn
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-10 22:03:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-10 22:03:25 +0000
commit8cf3d7a4929ece2fd448d64e24e1e93cf2fbd58c (patch)
tree14fc2a67033728f4bddc2a673e581e0cbbcd5544 /extra/svn
parentcf5658d7fe04a648f50547162d4594d60d8a47c3 (diff)
downloadredmine-8cf3d7a4929ece2fd448d64e24e1e93cf2fbd58c.tar.gz
redmine-8cf3d7a4929ece2fd448d64e24e1e93cf2fbd58c.zip
Replaces the repositories management SOAP API with a simple REST API.
reposman usage is unchanged but the script now requires activeresource. actionwebservice is now longer used and thus removed from plugins. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2435 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'extra/svn')
-rwxr-xr-xextra/svn/reposman.rb30
1 files changed, 18 insertions, 12 deletions
diff --git a/extra/svn/reposman.rb b/extra/svn/reposman.rb
index 46cc82cee..84e9bc2da 100755
--- a/extra/svn/reposman.rb
+++ b/extra/svn/reposman.rb
@@ -57,11 +57,10 @@
require 'getoptlong'
require 'rdoc/usage'
-require 'soap/wsdlDriver'
require 'find'
require 'etc'
-Version = "1.1"
+Version = "1.2"
SUPPORTED_SCM = %w( Subversion Darcs Mercurial Bazaar Git Filesystem )
opts = GetoptLong.new(
@@ -164,21 +163,28 @@ unless File.directory?($repos_base)
log("directory '#{$repos_base}' doesn't exists", :exit => true)
end
+begin
+ require 'activeresource'
+rescue LoadError
+ log("This script requires activeresource.\nRun 'gem install activeresource' to install it.", :exit => true)
+end
+
+class Project < ActiveResource::Base; end
+
log("querying Redmine for projects...", :level => 1);
$redmine_host.gsub!(/^/, "http://") unless $redmine_host.match("^https?://")
$redmine_host.gsub!(/\/$/, '')
-wsdl_url = "#{$redmine_host}/sys/service.wsdl";
+Project.site = "#{$redmine_host}/sys";
begin
- soap = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
+ # Get all active projects that have the Repository module enabled
+ projects = Project.find(:all)
rescue => e
- log("Unable to connect to #{wsdl_url} : #{e}", :exit => true)
+ log("Unable to connect to #{Project.site}: #{e}", :exit => true)
end
-projects = soap.ProjectsWithRepositoryEnabled
-
if projects.nil?
log('no project found, perhaps you forgot to "Enable WS for repository management"', :exit => true)
end
@@ -247,7 +253,7 @@ projects.each do |project|
else
# if repository is already declared in redmine, we don't create
# unless user use -f with reposman
- if $force == false and not project.repository.nil?
+ if $force == false and project.respond_to?(:repository)
log("\trepository for project #{project.identifier} already exists in Redmine", :level => 1)
next
end
@@ -274,11 +280,11 @@ projects.each do |project|
end
if $svn_url
- ret = soap.RepositoryCreated project.identifier, $scm, "#{$svn_url}#{project.identifier}"
- if ret > 0
+ begin
+ project.post(:repository, :vendor => $scm, :repository => {:url => "#{$svn_url}#{project.identifier}"})
log("\trepository #{repos_path} registered in Redmine with url #{$svn_url}#{project.identifier}");
- else
- log("\trepository #{repos_path} not registered in Redmine. Look in your log to find why.");
+ rescue => e
+ log("\trepository #{repos_path} not registered in Redmine: #{e.message}");
end
end