@@ -190,12 +190,12 task :migrate_from_mantis => :environment do | |||
|
190 | 190 | end |
|
191 | 191 | |
|
192 | 192 | def read(*args) |
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
193 | if @read_finished | |
|
194 | nil | |
|
195 | else | |
|
196 | @read_finished = true | |
|
197 | content | |
|
198 | end | |
|
199 | 199 | end |
|
200 | 200 | end |
|
201 | 201 | |
@@ -242,18 +242,18 task :migrate_from_mantis => :environment do | |||
|
242 | 242 | users_map = {} |
|
243 | 243 | users_migrated = 0 |
|
244 | 244 | MantisUser.find(:all).each do |user| |
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
245 | u = User.new :firstname => encode(user.firstname), | |
|
246 | :lastname => encode(user.lastname), | |
|
247 | :mail => user.email, | |
|
248 | :last_login_on => user.last_visit | |
|
249 | u.login = user.username | |
|
250 | u.password = 'mantis' | |
|
251 | u.status = User::STATUS_LOCKED if user.enabled != 1 | |
|
252 | u.admin = true if user.access_level == 90 | |
|
253 | next unless u.save! | |
|
254 | users_migrated += 1 | |
|
255 | users_map[user.id] = u.id | |
|
256 | print '.' | |
|
257 | 257 | end |
|
258 | 258 | puts |
|
259 | 259 | |
@@ -264,43 +264,43 task :migrate_from_mantis => :environment do | |||
|
264 | 264 | versions_map = {} |
|
265 | 265 | categories_map = {} |
|
266 | 266 | MantisProject.find(:all).each do |project| |
|
267 |
|
|
|
267 | p = Project.new :name => encode(project.name), | |
|
268 | 268 | :description => encode(project.description) |
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
|
269 | p.identifier = project.identifier | |
|
270 | next unless p.save | |
|
271 | projects_map[project.id] = p.id | |
|
272 | p.enabled_module_names = ['issue_tracking', 'news', 'wiki'] | |
|
273 | 273 | p.trackers << TRACKER_BUG unless p.trackers.include?(TRACKER_BUG) |
|
274 | 274 | p.trackers << TRACKER_FEATURE unless p.trackers.include?(TRACKER_FEATURE) |
|
275 |
|
|
|
276 | ||
|
277 |
|
|
|
278 |
|
|
|
275 | print '.' | |
|
276 | ||
|
277 | # Project members | |
|
278 | project.members.each do |member| | |
|
279 | 279 | m = Member.new :user => User.find_by_id(users_map[member.user_id]), |
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 | ||
|
285 |
|
|
|
286 |
|
|
|
280 | :roles => [ROLE_MAPPING[member.access_level] || DEFAULT_ROLE] | |
|
281 | m.project = p | |
|
282 | m.save | |
|
283 | end | |
|
284 | ||
|
285 | # Project versions | |
|
286 | project.versions.each do |version| | |
|
287 | 287 | v = Version.new :name => encode(version.version), |
|
288 | 288 | :description => encode(version.description), |
|
289 | 289 | :effective_date => (version.date_order ? version.date_order.to_date : nil) |
|
290 | 290 | v.project = p |
|
291 | 291 | v.save |
|
292 | 292 | versions_map[version.id] = v.id |
|
293 |
|
|
|
294 | ||
|
295 |
|
|
|
296 |
|
|
|
293 | end | |
|
294 | ||
|
295 | # Project categories | |
|
296 | project.categories.each do |category| | |
|
297 | 297 | g = IssueCategory.new :name => category.category[0,30] |
|
298 | 298 | g.project = p |
|
299 | 299 | g.save |
|
300 | 300 | categories_map[category.category] = g.id |
|
301 |
|
|
|
302 |
end |
|
|
303 |
puts |
|
|
301 | end | |
|
302 | end | |
|
303 | puts | |
|
304 | 304 | |
|
305 | 305 | # Bugs |
|
306 | 306 | print "Migrating bugs" |
@@ -309,22 +309,22 task :migrate_from_mantis => :environment do | |||
|
309 | 309 | keep_bug_ids = (Issue.count == 0) |
|
310 | 310 | MantisBug.find_each(:batch_size => 200) do |bug| |
|
311 | 311 | next unless projects_map[bug.project_id] && users_map[bug.reporter_id] |
|
312 |
|
|
|
312 | i = Issue.new :project_id => projects_map[bug.project_id], | |
|
313 | 313 | :subject => encode(bug.summary), |
|
314 | 314 | :description => encode(bug.bug_text.full_description), |
|
315 | 315 | :priority => PRIORITY_MAPPING[bug.priority] || DEFAULT_PRIORITY, |
|
316 | 316 | :created_on => bug.date_submitted, |
|
317 | 317 | :updated_on => bug.last_updated |
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 | STDOUT.flush | |
|
318 | i.author = User.find_by_id(users_map[bug.reporter_id]) | |
|
319 | i.category = IssueCategory.find_by_project_id_and_name(i.project_id, bug.category[0,30]) unless bug.category.blank? | |
|
320 | i.fixed_version = Version.find_by_project_id_and_name(i.project_id, bug.fixed_in_version) unless bug.fixed_in_version.blank? | |
|
321 | i.status = STATUS_MAPPING[bug.status] || DEFAULT_STATUS | |
|
322 | i.tracker = (bug.severity == 10 ? TRACKER_FEATURE : TRACKER_BUG) | |
|
323 | i.id = bug.id if keep_bug_ids | |
|
324 | next unless i.save | |
|
325 | issues_map[bug.id] = i.id | |
|
326 | print '.' | |
|
327 | STDOUT.flush | |
|
328 | 328 | |
|
329 | 329 | # Assignee |
|
330 | 330 | # Redmine checks that the assignee is a project member |
@@ -332,17 +332,17 task :migrate_from_mantis => :environment do | |||
|
332 | 332 | i.assigned_to = User.find_by_id(users_map[bug.handler_id]) |
|
333 | 333 | i.save(:validate => false) |
|
334 | 334 | end |
|
335 | ||
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
335 | ||
|
336 | # Bug notes | |
|
337 | bug.bug_notes.each do |note| | |
|
338 | next unless users_map[note.reporter_id] | |
|
339 | 339 | n = Journal.new :notes => encode(note.bug_note_text.note), |
|
340 | 340 | :created_on => note.date_submitted |
|
341 | 341 | n.user = User.find_by_id(users_map[note.reporter_id]) |
|
342 | 342 | n.journalized = i |
|
343 | 343 | n.save |
|
344 |
|
|
|
345 | ||
|
344 | end | |
|
345 | ||
|
346 | 346 | # Bug files |
|
347 | 347 | bug.bug_files.each do |file| |
|
348 | 348 | a = Attachment.new :created_on => file.date_added |
@@ -481,7 +481,7 task :migrate_from_mantis => :environment do | |||
|
481 | 481 | :username => 'root', |
|
482 | 482 | :password => '' } |
|
483 | 483 | |
|
484 |
puts |
|
|
484 | puts | |
|
485 | 485 | puts "Please enter settings for your Mantis database" |
|
486 | 486 | [:adapter, :host, :database, :username, :password].each do |param| |
|
487 | 487 | print "#{param} [#{db_params[param]}]: " |
General Comments 0
You need to be logged in to leave comments.
Login now