@@ -90,9 +90,10 $test = false | |||
|
90 | 90 | $force = false |
|
91 | 91 | $scm = 'Subversion' |
|
92 | 92 | |
|
93 | def log(text,level=0, exit=false) | |
|
93 | def log(text, options={}) | |
|
94 | level = options[:level] || 0 | |
|
94 | 95 | puts text unless $quiet or level > $verbose |
|
95 | exit 1 if exit | |
|
96 | exit 1 if options[:exit] | |
|
96 | 97 | end |
|
97 | 98 | |
|
98 | 99 | def system_or_raise(command) |
@@ -126,7 +127,7 begin | |||
|
126 | 127 | when '--redmine-host'; $redmine_host = arg.dup |
|
127 | 128 | when '--owner'; $svn_owner = arg.dup; $use_groupid = false; |
|
128 | 129 | when '--url'; $svn_url = arg.dup |
|
129 |
when '--scm'; $scm = arg.dup.capitalize; log("Invalid SCM: #{$scm}", |
|
|
130 | when '--scm'; $scm = arg.dup.capitalize; log("Invalid SCM: #{$scm}", :exit => true) unless SUPPORTED_SCM.include?($scm) | |
|
130 | 131 | when '--command'; $command = arg.dup |
|
131 | 132 | when '--verbose'; $verbose += 1 |
|
132 | 133 | when '--test'; $test = true |
@@ -149,7 +150,7 if $command.nil? | |||
|
149 | 150 | begin |
|
150 | 151 | scm_module = SCM.const_get($scm) |
|
151 | 152 | rescue |
|
152 |
log("Please use --command option to specify how to create a #{$scm} repository.", |
|
|
153 | log("Please use --command option to specify how to create a #{$scm} repository.", :exit => true) | |
|
153 | 154 | end |
|
154 | 155 | end |
|
155 | 156 | |
@@ -160,10 +161,10 if ($redmine_host.empty? or $repos_base.empty?) | |||
|
160 | 161 | end |
|
161 | 162 | |
|
162 | 163 | unless File.directory?($repos_base) |
|
163 |
log("directory '#{$repos_base}' doesn't exists", |
|
|
164 | log("directory '#{$repos_base}' doesn't exists", :exit => true) | |
|
164 | 165 | end |
|
165 | 166 | |
|
166 | log("querying Redmine for projects...", 1); | |
|
167 | log("querying Redmine for projects...", :level => 1); | |
|
167 | 168 | |
|
168 | 169 | $redmine_host.gsub!(/^/, "http://") unless $redmine_host.match("^https?://") |
|
169 | 170 | $redmine_host.gsub!(/\/$/, '') |
@@ -173,16 +174,16 wsdl_url = "#{$redmine_host}/sys/service.wsdl"; | |||
|
173 | 174 | begin |
|
174 | 175 | soap = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver |
|
175 | 176 | rescue => e |
|
176 |
log("Unable to connect to #{wsdl_url} : #{e}", |
|
|
177 | log("Unable to connect to #{wsdl_url} : #{e}", :exit => true) | |
|
177 | 178 | end |
|
178 | 179 | |
|
179 | 180 | projects = soap.ProjectsWithRepositoryEnabled |
|
180 | 181 | |
|
181 | 182 | if projects.nil? |
|
182 |
log('no project found, perhaps you forgot to "Enable WS for repository management"', |
|
|
183 | log('no project found, perhaps you forgot to "Enable WS for repository management"', :exit => true) | |
|
183 | 184 | end |
|
184 | 185 | |
|
185 | log("retrieved #{projects.size} projects", 1) | |
|
186 | log("retrieved #{projects.size} projects", :level => 1) | |
|
186 | 187 | |
|
187 | 188 | def set_owner_and_rights(project, repos_path, &block) |
|
188 | 189 | if RUBY_PLATFORM =~ /mswin/ |
@@ -209,7 +210,7 def owner_name(file) | |||
|
209 | 210 | end |
|
210 | 211 | |
|
211 | 212 | projects.each do |project| |
|
212 | log("treating project #{project.name}", 1) | |
|
213 | log("treating project #{project.name}", :level => 1) | |
|
213 | 214 | |
|
214 | 215 | if project.identifier.empty? |
|
215 | 216 | log("\tno identifier for project #{project.name}") |
@@ -247,7 +248,7 projects.each do |project| | |||
|
247 | 248 | # if repository is already declared in redmine, we don't create |
|
248 | 249 | # unless user use -f with reposman |
|
249 | 250 | if $force == false and not project.repository.nil? |
|
250 | log("\trepository for project #{project.identifier} already exists in Redmine", 1) | |
|
251 | log("\trepository for project #{project.identifier} already exists in Redmine", :level => 1) | |
|
251 | 252 | next |
|
252 | 253 | end |
|
253 | 254 |
General Comments 0
You need to be logged in to leave comments.
Login now