Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Extend migrate_from_trac.rake in order to import the 'found in version' field #41

Closed
wants to merge 2 commits into from

1 participant

Gilles Cornu
Gilles Cornu

Related Patch Ticket is http://www.redmine.org/issues/9181

Note: Changes for this pull request have been extracted from a larger set of changes

added some commits July 03, 2011
Gilles Cornu Improved migrate_from_trac script. Changes Micro Summary:
 * (top useful) task to convert SVN commit messages and authors after
Trac data has been imported into Redmine
 * (many community contributions) Integration of all the fixes and
enhancements
referenced in discussion http://www.redmine.org/boards/1/topics/12273
(since March 2010)
 * (my small contributions) Ability to import 'released version' field
from
Trac
taking advantage of Feature 2096 (Custom fields referencing system
tables: users and versions)
e2ba962
Gilles Cornu Import 'found in version' field from Trac as custom field based on type
'version' (available since Redmine 1.2.0 with feature
http://www.redmine.org/issues/2096)

Patch extracted for http://www.redmine.org/issues/9181
f377cc0
Toshi MARUYAMA marutosi referenced this pull request from a commit September 23, 2012
Commit has since been removed from the repository and is no longer available.
Gilles Cornu gildegoma closed this April 15, 2014
Gilles Cornu gildegoma deleted the branch April 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jul 03, 2011
Gilles Cornu Improved migrate_from_trac script. Changes Micro Summary:
 * (top useful) task to convert SVN commit messages and authors after
Trac data has been imported into Redmine
 * (many community contributions) Integration of all the fixes and
enhancements
referenced in discussion http://www.redmine.org/boards/1/topics/12273
(since March 2010)
 * (my small contributions) Ability to import 'released version' field
from
Trac
taking advantage of Feature 2096 (Custom fields referencing system
tables: users and versions)
e2ba962
Sep 04, 2011
Gilles Cornu Import 'found in version' field from Trac as custom field based on type
'version' (available since Redmine 1.2.0 with feature
http://www.redmine.org/issues/2096)

Patch extracted for http://www.redmine.org/issues/9181
f377cc0
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 33 additions and 2 deletions. Show diff stats Hide diff stats

  1. 35  lib/tasks/migrate_from_trac.rake
35  lib/tasks/migrate_from_trac.rake
... ...
@@ -1,5 +1,8 @@
1  
-# redMine - project management software
2  
-# Copyright (C) 2006-2007  Jean-Philippe Lang
  1
+# Redmine - project management software
  2
+# Copyright (C) 2006-2011  Jean-Philippe Lang
  3
+# Copyright (C) 2007-2011  Trac/Redmine Community
  4
+# References:
  5
+#  - http://www.redmine.org/boards/1/topics/12273 (Trac Importer Patch Coordination)
3 6
 #
4 7
 # This program is free software; you can redistribute it and/or
5 8
 # modify it under the terms of the GNU General Public License
@@ -456,6 +459,21 @@ namespace :redmine do
456 459
         r.save!
457 460
         custom_field_map['resolution'] = r
458 461
 
  462
+        # Trac 'version' field as a Redmine custom field, taking advantage of feature #2096 (available since Redmine 1.2.0)
  463
+        v = IssueCustomField.find(:first, :conditions => { :name => "Found in Version" })
  464
+        v = IssueCustomField.new(:name => 'Found in Version',
  465
+                                 :field_format => 'version',
  466
+                                 :is_filter => true) if v.nil?
  467
+        # Only apply to BUG tracker (?)
  468
+        v.trackers << TRACKER_BUG
  469
+        #v.trackers << [TRACKER_BUG, TRACKER_FEATURE]
  470
+
  471
+        # Affect custom field to current Project
  472
+        v.projects << @target_project
  473
+
  474
+        v.save!
  475
+        custom_field_map['found_in_version'] = v
  476
+  
459 477
         # Tickets
460 478
         print "Migrating tickets"
461 479
           TracTicket.find_each(:batch_size => 200) do |ticket|
@@ -534,6 +552,19 @@ namespace :redmine do
534 552
           if custom_field_map['resolution'] && !ticket.resolution.blank?
535 553
             custom_values[custom_field_map['resolution'].id] = ticket.resolution
536 554
           end
  555
+
  556
+          if !ticket.version.blank? && custom_field_map['found_in_version']
  557
+            found_in = version_map[ticket.version]
  558
+            if !found_in.nil?
  559
+              puts "Issue #{i.id} found in #{found_in.name.to_s} (#{found_in.id.to_s}) - trac: #{ticket.version}"
  560
+            else
  561
+              #TODO: add better error management here...
  562
+              puts "Issue #{i.id} : ouch...  - trac: #{ticket.version}"  
  563
+            end 
  564
+            custom_values[custom_field_map['found_in_version'].id] = found_in.id.to_s
  565
+            STDOUT.flush
  566
+          end
  567
+
537 568
           i.custom_field_values = custom_values
538 569
           i.save_custom_field_values
539 570
         end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.