@@ -90,7 +90,7 namespace :redmine do | |||
|
90 | 90 | |
|
91 | 91 | class TracMilestone < ActiveRecord::Base |
|
92 | 92 | set_table_name :milestone |
|
93 | ||
|
93 | # If this attribute is set a milestone has a defined target timepoint | |
|
94 | 94 | def due |
|
95 | 95 | if read_attribute(:due) && read_attribute(:due) > 0 |
|
96 | 96 | Time.at(read_attribute(:due)).to_date |
@@ -98,6 +98,14 namespace :redmine do | |||
|
98 | 98 | nil |
|
99 | 99 | end |
|
100 | 100 | end |
|
101 | # This is the real timepoint at which the milestone has finished. | |
|
102 | def completed | |
|
103 | if read_attribute(:completed) && read_attribute(:completed) > 0 | |
|
104 | Time.at(read_attribute(:completed)).to_date | |
|
105 | else | |
|
106 | nil | |
|
107 | end | |
|
108 | end | |
|
101 | 109 | |
|
102 | 110 | def description |
|
103 | 111 | # Attribute is named descr in Trac v0.8.x |
@@ -284,9 +292,38 namespace :redmine do | |||
|
284 | 292 | s |
|
285 | 293 | end |
|
286 | 294 | end |
|
287 | # Preformatted blocks | |
|
288 | text = text.gsub(/\{\{\{/, '<pre>') | |
|
289 | text = text.gsub(/\}\}\}/, '</pre>') | |
|
295 | # We would like to convert the Code highlighting too | |
|
296 | # This will go into the next line. | |
|
297 | shebang_line = false | |
|
298 | # Reguar expression for start of code | |
|
299 | pre_re = /\{\{\{/ | |
|
300 | # Code hightlighing... | |
|
301 | shebang_re = /^\#\!([a-z]+)/ | |
|
302 | # Regular expression for end of code | |
|
303 | pre_end_re = /\}\}\}/ | |
|
304 | ||
|
305 | # Go through the whole text..extract it line by line | |
|
306 | text = text.gsub(/^(.*)$/) do |line| | |
|
307 | m_pre = pre_re.match(line) | |
|
308 | if m_pre | |
|
309 | line = '<pre>' | |
|
310 | else | |
|
311 | m_sl = shebang_re.match(line) | |
|
312 | if m_sl | |
|
313 | shebang_line = true | |
|
314 | line = '<code class="' + m_sl[1] + '">' | |
|
315 | end | |
|
316 | m_pre_end = pre_end_re.match(line) | |
|
317 | if m_pre_end | |
|
318 | line = '</pre>' | |
|
319 | if shebang_line | |
|
320 | line = '</code>' + line | |
|
321 | end | |
|
322 | end | |
|
323 | end | |
|
324 | line | |
|
325 | end | |
|
326 | ||
|
290 | 327 | # Highlighting |
|
291 | 328 | text = text.gsub(/'''''([^\s])/, '_*\1') |
|
292 | 329 | text = text.gsub(/([^\s])'''''/, '\1*_') |
@@ -315,6 +352,12 namespace :redmine do | |||
|
315 | 352 | migrated_ticket_attachments = 0 |
|
316 | 353 | migrated_wiki_edits = 0 |
|
317 | 354 | migrated_wiki_attachments = 0 |
|
355 | ||
|
356 | #Wiki system initializing... | |
|
357 | @target_project.wiki.destroy if @target_project.wiki | |
|
358 | @target_project.reload | |
|
359 | wiki = Wiki.new(:project => @target_project, :start_page => 'WikiStart') | |
|
360 | wiki_edit_count = 0 | |
|
318 | 361 | |
|
319 | 362 | # Components |
|
320 | 363 | print "Migrating components" |
@@ -336,10 +379,20 namespace :redmine do | |||
|
336 | 379 | TracMilestone.find(:all).each do |milestone| |
|
337 | 380 | print '.' |
|
338 | 381 | STDOUT.flush |
|
382 | # First we try to find the wiki page... | |
|
383 | p = wiki.find_or_new_page(milestone.name.to_s) | |
|
384 | p.content = WikiContent.new(:page => p) if p.new_record? | |
|
385 | p.content.text = milestone.description.to_s | |
|
386 | p.content.author = find_or_create_user('trac') | |
|
387 | p.content.comments = 'Milestone' | |
|
388 | p.save | |
|
389 | ||
|
339 | 390 | v = Version.new :project => @target_project, |
|
340 | 391 | :name => encode(milestone.name[0, limit_for(Version, 'name')]), |
|
341 | :description => encode(milestone.description.to_s[0, limit_for(Version, 'description')]), | |
|
342 |
: |
|
|
392 | :description => nil, | |
|
393 | :wiki_page_title => milestone.name.to_s, | |
|
394 | :effective_date => milestone.completed | |
|
395 | ||
|
343 | 396 | next unless v.save |
|
344 | 397 | version_map[milestone.name] = v |
|
345 | 398 | migrated_milestones += 1 |
@@ -462,10 +515,6 namespace :redmine do | |||
|
462 | 515 | |
|
463 | 516 | # Wiki |
|
464 | 517 | print "Migrating wiki" |
|
465 | @target_project.wiki.destroy if @target_project.wiki | |
|
466 | @target_project.reload | |
|
467 | wiki = Wiki.new(:project => @target_project, :start_page => 'WikiStart') | |
|
468 | wiki_edit_count = 0 | |
|
469 | 518 | if wiki.save |
|
470 | 519 | TracWikiPage.find(:all, :order => 'name, version').each do |page| |
|
471 | 520 | # Do not migrate Trac manual wiki pages |
@@ -678,3 +727,4 namespace :redmine do | |||
|
678 | 727 | TracMigrate.migrate |
|
679 | 728 | end |
|
680 | 729 | end |
|
730 |
General Comments 0
You need to be logged in to leave comments.
Login now