@@ -90,7 +90,7 namespace :redmine do | |||||
90 |
|
90 | |||
91 | class TracMilestone < ActiveRecord::Base |
|
91 | class TracMilestone < ActiveRecord::Base | |
92 | set_table_name :milestone |
|
92 | set_table_name :milestone | |
93 |
|
93 | # If this attribute is set a milestone has a defined target timepoint | ||
94 | def due |
|
94 | def due | |
95 | if read_attribute(:due) && read_attribute(:due) > 0 |
|
95 | if read_attribute(:due) && read_attribute(:due) > 0 | |
96 | Time.at(read_attribute(:due)).to_date |
|
96 | Time.at(read_attribute(:due)).to_date | |
@@ -98,6 +98,14 namespace :redmine do | |||||
98 | nil |
|
98 | nil | |
99 | end |
|
99 | end | |
100 | end |
|
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 | def description |
|
110 | def description | |
103 | # Attribute is named descr in Trac v0.8.x |
|
111 | # Attribute is named descr in Trac v0.8.x | |
@@ -284,9 +292,38 namespace :redmine do | |||||
284 | s |
|
292 | s | |
285 | end |
|
293 | end | |
286 | end |
|
294 | end | |
287 | # Preformatted blocks |
|
295 | # We would like to convert the Code highlighting too | |
288 | text = text.gsub(/\{\{\{/, '<pre>') |
|
296 | # This will go into the next line. | |
289 | text = text.gsub(/\}\}\}/, '</pre>') |
|
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 | # Highlighting |
|
327 | # Highlighting | |
291 | text = text.gsub(/'''''([^\s])/, '_*\1') |
|
328 | text = text.gsub(/'''''([^\s])/, '_*\1') | |
292 | text = text.gsub(/([^\s])'''''/, '\1*_') |
|
329 | text = text.gsub(/([^\s])'''''/, '\1*_') | |
@@ -316,6 +353,12 namespace :redmine do | |||||
316 | migrated_wiki_edits = 0 |
|
353 | migrated_wiki_edits = 0 | |
317 | migrated_wiki_attachments = 0 |
|
354 | migrated_wiki_attachments = 0 | |
318 |
|
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 | |||
|
361 | ||||
319 | # Components |
|
362 | # Components | |
320 | print "Migrating components" |
|
363 | print "Migrating components" | |
321 | issues_category_map = {} |
|
364 | issues_category_map = {} | |
@@ -336,10 +379,20 namespace :redmine do | |||||
336 | TracMilestone.find(:all).each do |milestone| |
|
379 | TracMilestone.find(:all).each do |milestone| | |
337 | print '.' |
|
380 | print '.' | |
338 | STDOUT.flush |
|
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 | v = Version.new :project => @target_project, |
|
390 | v = Version.new :project => @target_project, | |
340 | :name => encode(milestone.name[0, limit_for(Version, 'name')]), |
|
391 | :name => encode(milestone.name[0, limit_for(Version, 'name')]), | |
341 | :description => encode(milestone.description.to_s[0, limit_for(Version, 'description')]), |
|
392 | :description => nil, | |
342 |
: |
|
393 | :wiki_page_title => milestone.name.to_s, | |
|
394 | :effective_date => milestone.completed | |||
|
395 | ||||
343 | next unless v.save |
|
396 | next unless v.save | |
344 | version_map[milestone.name] = v |
|
397 | version_map[milestone.name] = v | |
345 | migrated_milestones += 1 |
|
398 | migrated_milestones += 1 | |
@@ -462,10 +515,6 namespace :redmine do | |||||
462 |
|
515 | |||
463 | # Wiki |
|
516 | # Wiki | |
464 | print "Migrating wiki" |
|
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 | if wiki.save |
|
518 | if wiki.save | |
470 | TracWikiPage.find(:all, :order => 'name, version').each do |page| |
|
519 | TracWikiPage.find(:all, :order => 'name, version').each do |page| | |
471 | # Do not migrate Trac manual wiki pages |
|
520 | # Do not migrate Trac manual wiki pages | |
@@ -678,3 +727,4 namespace :redmine do | |||||
678 | TracMigrate.migrate |
|
727 | TracMigrate.migrate | |
679 | end |
|
728 | end | |
680 | end |
|
729 | end | |
|
730 |
General Comments 0
You need to be logged in to leave comments.
Login now