Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions lib/tasks/migrate_from_trac.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
# Redmine - project management software
# Copyright (C) 2006-2011 Jean-Philippe Lang
# Copyright (C) 2007-2011 Trac/Redmine Community
# References:
# - http://www.redmine.org/boards/1/topics/12273 (Trac Importer Patch Coordination)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -456,6 +459,21 @@ namespace :redmine do
r.save!
custom_field_map['resolution'] = r

# Trac 'version' field as a Redmine custom field, taking advantage of feature #2096 (available since Redmine 1.2.0)
v = IssueCustomField.find(:first, :conditions => { :name => "Found in Version" })
v = IssueCustomField.new(:name => 'Found in Version',
:field_format => 'version',
:is_filter => true) if v.nil?
# Only apply to BUG tracker (?)
v.trackers << TRACKER_BUG
#v.trackers << [TRACKER_BUG, TRACKER_FEATURE]

# Affect custom field to current Project
v.projects << @target_project

v.save!
custom_field_map['found_in_version'] = v

# Tickets
print "Migrating tickets"
TracTicket.find_each(:batch_size => 200) do |ticket|
Expand Down Expand Up @@ -534,6 +552,19 @@ namespace :redmine do
if custom_field_map['resolution'] && !ticket.resolution.blank?
custom_values[custom_field_map['resolution'].id] = ticket.resolution
end

if !ticket.version.blank? && custom_field_map['found_in_version']
found_in = version_map[ticket.version]
if !found_in.nil?
puts "Issue #{i.id} found in #{found_in.name.to_s} (#{found_in.id.to_s}) - trac: #{ticket.version}"
else
#TODO: add better error management here...
puts "Issue #{i.id} : ouch... - trac: #{ticket.version}"
end
custom_values[custom_field_map['found_in_version'].id] = found_in.id.to_s
STDOUT.flush
end

i.custom_field_values = custom_values
i.save_custom_field_values
end
Expand Down