##// END OF EJS Templates
Removed unneeded #h calls in views....
Removed unneeded #h calls in views. git-svn-id: http://svn.redmine.org/redmine/trunk@14043 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r13490:000124f44f53
r13661:b778c51e9049
Show More
migrate_from_trac.rake
777 lines | 29.5 KiB | text/x-ruby | RubyLexer
/ lib / tasks / migrate_from_trac.rake
Toshi MARUYAMA
remove trailing white-spaces from lib/tasks/migrate_from_trac.rake...
r6954 # Redmine - project management software
Jean-Philippe Lang
Copyright update....
r13490 # Copyright (C) 2006-2015 Jean-Philippe Lang
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 #
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 #
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'active_record'
require 'pp'
namespace :redmine do
desc 'Trac migration script'
task :migrate_from_trac => :environment do
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 module TracMigrate
Jean-Philippe Lang
Trac importer:...
r933 TICKET_MAP = []
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Default status per tracker (#5991)....
r13153 new_status = IssueStatus.find_by_position(1)
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 assigned_status = IssueStatus.find_by_position(2)
resolved_status = IssueStatus.find_by_position(3)
feedback_status = IssueStatus.find_by_position(4)
Jean-Philippe Lang
Replaces find(:first/:all) calls....
r10704 closed_status = IssueStatus.where(:is_closed => true).first
Jean-Philippe Lang
Default status per tracker (#5991)....
r13153 STATUS_MAPPING = {'new' => new_status,
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 'reopened' => feedback_status,
'assigned' => assigned_status,
'closed' => closed_status
}
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Removes column opt in enumerations table....
r3126 priorities = IssuePriority.all
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 DEFAULT_PRIORITY = priorities[0]
PRIORITY_MAPPING = {'lowest' => priorities[0],
'low' => priorities[0],
'normal' => priorities[1],
'high' => priorities[2],
Jean-Philippe Lang
Trac importer fix:...
r1161 'highest' => priorities[3],
# ---
'trivial' => priorities[0],
'minor' => priorities[1],
'major' => priorities[2],
'critical' => priorities[3],
'blocker' => priorities[4]
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 }
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 TRACKER_BUG = Tracker.find_by_position(1)
TRACKER_FEATURE = Tracker.find_by_position(2)
DEFAULT_TRACKER = TRACKER_BUG
TRACKER_MAPPING = {'defect' => TRACKER_BUG,
'enhancement' => TRACKER_FEATURE,
'task' => TRACKER_FEATURE,
'patch' =>TRACKER_FEATURE
}
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Replaces find(:all) calls....
r10690 roles = Role.where(:builtin => 0).order('position ASC').all
Jean-Philippe Lang
Fixed Mantis importer: projects trackers and modules assignment...
r923 manager_role = roles[0]
developer_role = roles[1]
DEFAULT_ROLE = roles.last
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 ROLE_MAPPING = {'admin' => manager_role,
'developer' => developer_role
}
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Fixed: migrate_from_trac doesn't import timestamps of wiki and tickets (patch #882 by Andreas Neuhaus slightly edited)....
r1287 class ::Time
class << self
alias :real_now :now
def now
real_now - @fake_diff.to_i
end
def fake(time)
@fake_diff = real_now - time
res = yield
@fake_diff = 0
res
end
end
end
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 class TracComponent < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :component
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 class TracMilestone < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :milestone
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 # If this attribute is set a milestone has a defined target timepoint
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def due
Jean-Philippe Lang
Fixed: error on Trac import when :due attribute is nil (#1164)....
r1391 if read_attribute(:due) && read_attribute(:due) > 0
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 Time.at(read_attribute(:due)).to_date
else
nil
end
end
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009 # This is the real timepoint at which the milestone has finished.
def completed
if read_attribute(:completed) && read_attribute(:completed) > 0
Time.at(read_attribute(:completed)).to_date
else
nil
end
end
Jean-Philippe Lang
Makes importer work with Trac 0.8.x (#1540)....
r1583
def description
# Attribute is named descr in Trac v0.8.x
has_attribute?(:descr) ? read_attribute(:descr) : read_attribute(:description)
end
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 class TracTicketCustom < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :ticket_custom
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 class TracAttachment < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :attachment
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 set_inheritance_column :none
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def time; Time.at(read_attribute(:time)) end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def original_filename
filename
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def content_type
Jean-Philippe Lang
Auto-detect attachment content type when blank (#3782)....
r3144 ''
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def exist?
File.file? trac_fullpath
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Fixed Trac importer broken by r2670 (#3254)....
r2609 def open
File.open("#{trac_fullpath}", 'rb') {|f|
@file = f
yield self
}
end
def read(*args)
@file.read(*args)
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: migrate attachments descriptions (#1326)....
r1463 def description
read_attribute(:description).to_s.slice(0,255)
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 private
def trac_fullpath
attachment_type = read_attribute(:type)
Jean-Baptiste Barth
Fix Trac importer breaking on exotic characters with ruby 1.9+ (#13990)....
r11566 #replace exotic characters with their hex representation to avoid invalid filenames
trac_file = filename.gsub( /[^a-zA-Z0-9\-_\.!~*']/n ) do |x|
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 codepoint = x.codepoints.to_a[0]
Jean-Baptiste Barth
Fix Trac importer breaking on exotic characters with ruby 1.9+ (#13990)....
r11566 sprintf('%%%02x', codepoint)
end
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 "#{TracMigrate.trac_attachments_directory}/#{attachment_type}/#{id}/#{trac_file}"
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 class TracTicket < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :ticket
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 set_inheritance_column :none
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 # ticket changes: only migrate status changes and comments
Jean-Philippe Lang
Renamed #changes association to #ticket_changes....
r9577 has_many :ticket_changes, :class_name => "TracTicketChange", :foreign_key => :ticket
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 has_many :customs, :class_name => "TracTicketCustom", :foreign_key => :ticket
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Makes migrate_from_trac compatible with Rails3....
r9397 def attachments
TracMigrate::TracAttachment.all(:conditions => ["type = 'ticket' AND id = ?", self.id.to_s])
end
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 def ticket_type
read_attribute(:type)
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 def summary
read_attribute(:summary).blank? ? "(no subject)" : read_attribute(:summary)
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 def description
read_attribute(:description).blank? ? summary : read_attribute(:description)
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 def time; Time.at(read_attribute(:time)) end
Jean-Philippe Lang
Fixed: migrate_from_trac doesn't import timestamps of wiki and tickets (patch #882 by Andreas Neuhaus slightly edited)....
r1287 def changetime; Time.at(read_attribute(:changetime)) end
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 class TracTicketChange < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :ticket_change
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Makes migrate_from_trac compatible with Rails3....
r9397 def self.columns
# Hides Trac field 'field' to prevent clash with AR field_changed? method (Rails 3.0)
super.select {|column| column.name.to_s != 'field'}
end
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 def time; Time.at(read_attribute(:time)) end
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: exclude more Trac wiki pages (#933)....
r1282 TRAC_WIKI_PAGES = %w(InterMapTxt InterTrac InterWiki RecentChanges SandBox TracAccessibility TracAdmin TracBackup TracBrowser TracCgi TracChangeset \
Jean-Philippe Lang
Trac importer fix:...
r1161 TracEnvironment TracFastCgi TracGuide TracImport TracIni TracInstall TracInterfaceCustomization \
TracLinks TracLogging TracModPython TracNotification TracPermissions TracPlugins TracQuery \
Jean-Philippe Lang
Trac importer: exclude more Trac wiki pages (#933)....
r1282 TracReports TracRevisionLog TracRoadmap TracRss TracSearch TracStandalone TracSupport TracSyntaxColoring TracTickets \
Jean-Philippe Lang
Trac importer fix:...
r1161 TracTicketsCustomFields TracTimeline TracUnicode TracUpgrade TracWiki WikiDeletePage WikiFormatting \
WikiHtml WikiMacros WikiNewPage WikiPageNames WikiProcessors WikiRestructuredText WikiRestructuredTextLinks \
CamelCase TitleIndex)
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 class TracWikiPage < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :wiki
Jean-Philippe Lang
Trac importer fix:...
r1161 set_primary_key :name
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Fixed Trac importer error with Rails 2.0: readonly? is defined by ActiveRecord....
r982 def self.columns
# Hides readonly Trac field to prevent clash with AR readonly? method (Rails 2.0)
super.select {|column| column.name.to_s != 'readonly'}
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Makes migrate_from_trac compatible with Rails3....
r9397 def attachments
TracMigrate::TracAttachment.all(:conditions => ["type = 'wiki' AND id = ?", self.id.to_s])
end
Jean-Philippe Lang
Fixed: migrate_from_trac doesn't import timestamps of wiki and tickets (patch #882 by Andreas Neuhaus slightly edited)....
r1287 def time; Time.at(read_attribute(:time)) end
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 class TracPermission < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :permission
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: read session_attribute table to find user's email and real name (#1340)....
r1488 class TracSessionAttribute < ActiveRecord::Base
Jean-Philippe Lang
set_table_name deprecated....
r9368 self.table_name = :session_attribute
Jean-Philippe Lang
Trac importer: read session_attribute table to find user's email and real name (#1340)....
r1488 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def self.find_or_create_user(username, project_member = false)
Jean-Philippe Lang
Trac importer: handle nil usernames....
r1111 return User.anonymous if username.blank?
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 u = User.find_by_login(username)
if !u
# Create a new user if not found
Jean-Philippe Lang
Increase username length limit from 30 to 60 (#2719)....
r8658 mail = username[0, User::MAIL_LENGTH_LIMIT]
Jean-Philippe Lang
Trac importer: read session_attribute table to find user's email and real name (#1340)....
r1488 if mail_attr = TracSessionAttribute.find_by_sid_and_name(username, 'email')
mail = mail_attr.value
end
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 mail = "#{mail}@foo.bar" unless mail.include?("@")
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: read session_attribute table to find user's email and real name (#1340)....
r1488 name = username
if name_attr = TracSessionAttribute.find_by_sid_and_name(username, 'name')
name = name_attr.value
end
Jean-Philippe Lang
migrate_from_trac.rake does not properly parse First Name and Last Name (#14592)....
r11934 name =~ (/(\w+)(\s+\w+)?/)
fn = ($1 || "-").strip
Jean-Philippe Lang
Trac importer: read session_attribute table to find user's email and real name (#1340)....
r1488 ln = ($2 || '-').strip
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: read session_attribute table to find user's email and real name (#1340)....
r1488 u = User.new :mail => mail.gsub(/[^-@a-z0-9\.]/i, '-'),
Jean-Philippe Lang
Remove the limitation on characters that can be used in custom_field, issue_status, role, tracker, user names (#5152)....
r4479 :firstname => fn[0, limit_for(User, 'firstname')],
:lastname => ln[0, limit_for(User, 'lastname')]
Jean-Philippe Lang
Trac importer: read session_attribute table to find user's email and real name (#1340)....
r1488
Jean-Philippe Lang
Increase username length limit from 30 to 60 (#2719)....
r8658 u.login = username[0, User::LOGIN_LENGTH_LIMIT].gsub(/[^a-z0-9_\-@\.]/i, '-')
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 u.password = 'trac'
u.admin = true if TracPermission.find_by_username_and_action(username, 'admin')
# finally, a default user is used if the new user is not valid
Jean-Philippe Lang
Replaces find(:first) calls....
r10701 u = User.first unless u.save
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Toshi MARUYAMA
gender neutral source comment at lib/tasks/migrate_from_trac.rake...
r11760 # Make sure user is a member of the project
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 if project_member && !u.member_of?(@target_project)
role = DEFAULT_ROLE
if u.admin
role = ROLE_MAPPING['admin']
elsif TracPermission.find_by_username_and_action(username, 'developer')
role = ROLE_MAPPING['developer']
end
Jean-Philippe Lang
Fixes migration scripts broken by r2726....
r2808 Member.create(:user => u, :project => @target_project, :roles => [role])
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 u.reload
end
u
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 # Basic wiki syntax conversion
def self.convert_wiki_text(text)
# Titles
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 text = text.gsub(/^(\=+)\s(.+)\s(\=+)/) {|s| "\nh#{$1.length}. #{$2}\n"}
# External Links
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 text = text.gsub(/\[(http[^\s]+)\s+([^\]]+)\]/) {|s| "\"#{$2}\":#{$1}"}
Jean-Philippe Lang
Fixed: Trac milestone links not correctly converted (#2052)....
r2012 # Ticket links:
Jean-Philippe Lang
Fixed: Trac migration of ticket:123 or [ticket:34] do not work (#2053)....
r2010 # [ticket:234 Text],[ticket:234 This is a test]
Jean-Philippe Lang
Fixed: Trac migration of ticket:123 or [ticket:34] do not work (#2053)....
r2011 text = text.gsub(/\[ticket\:([^\ ]+)\ (.+?)\]/, '"\2":/issues/show/\1')
Jean-Philippe Lang
Fixed: Trac migration of ticket:123 or [ticket:34] do not work (#2053)....
r2010 # ticket:1234
# #1 is working cause Redmine uses the same syntax.
text = text.gsub(/ticket\:([^\ ]+)/, '#\1')
Jean-Philippe Lang
Fixed: Trac milestone links not correctly converted (#2052)....
r2012 # Milestone links:
# [milestone:"0.1.0 Mercury" Milestone 0.1.0 (Mercury)]
# The text "Milestone 0.1.0 (Mercury)" is not converted,
# cause Redmine's wiki does not support this.
text = text.gsub(/\[milestone\:\"([^\"]+)\"\ (.+?)\]/, 'version:"\1"')
# [milestone:"0.1.0 Mercury"]
text = text.gsub(/\[milestone\:\"([^\"]+)\"\]/, 'version:"\1"')
text = text.gsub(/milestone\:\"([^\"]+)\"/, 'version:"\1"')
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 # milestone:0.1.0
Jean-Philippe Lang
Fixed: Trac milestone links not correctly converted (#2052)....
r2012 text = text.gsub(/\[milestone\:([^\ ]+)\]/, 'version:\1')
text = text.gsub(/milestone\:([^\ ]+)/, 'version:\1')
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 # Internal Links
Jean-Philippe Lang
Trac importer:...
r933 text = text.gsub(/\[\[BR\]\]/, "\n") # This has to go before the rules below
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 text = text.gsub(/\[\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"}
text = text.gsub(/\[wiki:\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"}
text = text.gsub(/\[wiki:\"(.+)\".*\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"}
Jean-Philippe Lang
Trac importer: improves wiki link conversion (#1287)....
r1480 text = text.gsub(/\[wiki:([^\s\]]+)\]/) {|s| "[[#{$1.delete(',./?;|:')}]]"}
text = text.gsub(/\[wiki:([^\s\]]+)\s(.*)\]/) {|s| "[[#{$1.delete(',./?;|:')}|#{$2.delete(',./?;|:')}]]"}
John Goerzen
Support WikiCaps for Trac migrations...
r1228
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 # Links to pages UsingJustWikiCaps
text = text.gsub(/([^!]|^)(^| )([A-Z][a-z]+[A-Z][a-zA-Z]+)/, '\\1\\2[[\3]]')
# Normalize things that were supposed to not be links
# like !NotALink
text = text.gsub(/(^| )!([A-Z][A-Za-z]+)/, '\1\2')
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 # Revisions links
text = text.gsub(/\[(\d+)\]/, 'r\1')
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 # Ticket number re-writing
text = text.gsub(/#(\d+)/) do |s|
Jean-Philippe Lang
Trac importer fix:...
r1161 if $1.length < 10
Jean-Philippe Lang
Removes a useless assignment in Trac importer (#4931)....
r3380 # TICKET_MAP[$1.to_i] ||= $1
Jean-Philippe Lang
Trac importer fix:...
r1161 "\##{TICKET_MAP[$1.to_i] || $1}"
else
s
end
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 end
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009 # We would like to convert the Code highlighting too
# This will go into the next line.
shebang_line = false
Toshi MARUYAMA
fix typos of migrate_from_trac.rake...
r12634 # Regular expression for start of code
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009 pre_re = /\{\{\{/
Toshi MARUYAMA
fix typos of migrate_from_trac.rake...
r12634 # Code highlighting...
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009 shebang_re = /^\#\!([a-z]+)/
# Regular expression for end of code
pre_end_re = /\}\}\}/
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009 # Go through the whole text..extract it line by line
text = text.gsub(/^(.*)$/) do |line|
m_pre = pre_re.match(line)
if m_pre
line = '<pre>'
else
m_sl = shebang_re.match(line)
if m_sl
shebang_line = true
line = '<code class="' + m_sl[1] + '">'
end
m_pre_end = pre_end_re.match(line)
if m_pre_end
line = '</pre>'
if shebang_line
line = '</code>' + line
end
end
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 line
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009 end
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 # Highlighting
text = text.gsub(/'''''([^\s])/, '_*\1')
text = text.gsub(/([^\s])'''''/, '\1*_')
text = text.gsub(/'''/, '*')
text = text.gsub(/''/, '_')
text = text.gsub(/__/, '+')
text = text.gsub(/~~/, '-')
text = text.gsub(/`/, '@')
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 text = text.gsub(/,,/, '~')
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 # Lists
text = text.gsub(/^([ ]+)\* /) {|s| '*' * $1.length + " "}
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 text
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def self.migrate
Jean-Philippe Lang
Trac importer:...
r933 establish_connection
Jean-Philippe Lang
Trac importer: user can now choose between sqlite and sqlite3 adapter for Trac database....
r881
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 # Quick database test
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 TracComponent.count
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 migrated_components = 0
migrated_milestones = 0
migrated_tickets = 0
migrated_custom_values = 0
migrated_ticket_attachments = 0
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 migrated_wiki_edits = 0
Jean-Philippe Lang
Trac importer fix:...
r1161 migrated_wiki_attachments = 0
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009
#Wiki system initializing...
@target_project.wiki.destroy if @target_project.wiki
@target_project.reload
wiki = Wiki.new(:project => @target_project, :start_page => 'WikiStart')
wiki_edit_count = 0
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 # Components
print "Migrating components"
issues_category_map = {}
Jean-Philippe Lang
Replaces find(:all) calls....
r10690 TracComponent.all.each do |component|
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 print '.'
STDOUT.flush
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 c = IssueCategory.new :project => @target_project,
:name => encode(component.name[0, limit_for(IssueCategory, 'name')])
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 next unless c.save
issues_category_map[component.name] = c
migrated_components += 1
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
puts
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 # Milestones
print "Migrating milestones"
version_map = {}
Jean-Philippe Lang
Replaces find(:all) calls....
r10690 TracMilestone.all.each do |milestone|
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 print '.'
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 STDOUT.flush
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009 # First we try to find the wiki page...
p = wiki.find_or_new_page(milestone.name.to_s)
p.content = WikiContent.new(:page => p) if p.new_record?
p.content.text = milestone.description.to_s
p.content.author = find_or_create_user('trac')
p.content.comments = 'Milestone'
p.save
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 v = Version.new :project => @target_project,
:name => encode(milestone.name[0, limit_for(Version, 'name')]),
Jean-Philippe Lang
Trac importer improvements (patch #2050 by Karl Heinz Marbaise)....
r2009 :description => nil,
:wiki_page_title => milestone.name.to_s,
:effective_date => milestone.completed
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 next unless v.save
version_map[milestone.name] = v
migrated_milestones += 1
end
puts
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 # Custom fields
# TODO: read trac.ini instead
Jean-Philippe Lang
Trac importer now migrates status changes....
r682 print "Migrating custom fields"
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 custom_field_map = {}
TracTicketCustom.find_by_sql("SELECT DISTINCT name FROM #{TracTicketCustom.table_name}").each do |field|
print '.'
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 STDOUT.flush
# Redmine custom field name
field_name = encode(field.name[0, limit_for(IssueCustomField, 'name')]).humanize
# Find if the custom already exists in Redmine
f = IssueCustomField.find_by_name(field_name)
# Or create a new one
f ||= IssueCustomField.create(:name => encode(field.name[0, limit_for(IssueCustomField, 'name')]).humanize,
:field_format => 'string')
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 next if f.new_record?
Jean-Philippe Lang
Replaces find(:all) calls....
r10690 f.trackers = Tracker.all
Jean-Philippe Lang
Trac importer now migrates status changes....
r682 f.projects << @target_project
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 custom_field_map[field.name] = f
end
puts
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 # Trac 'resolution' field as a Redmine custom field
Jean-Philippe Lang
Replaces find(:first) calls....
r10701 r = IssueCustomField.where(:name => "Resolution").first
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 r = IssueCustomField.new(:name => 'Resolution',
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 :field_format => 'list',
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 :is_filter => true) if r.nil?
Jean-Philippe Lang
Replaces find(:all) calls....
r10690 r.trackers = Tracker.all
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 r.projects << @target_project
Jean-Philippe Lang
Trac importer: prevent validation failure due to the default value when saving the Resolution custom field if it already exists (#869)....
r1271 r.possible_values = (r.possible_values + %w(fixed invalid wontfix duplicate worksforme)).flatten.compact.uniq
r.save!
custom_field_map['resolution'] = r
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 # Tickets
print "Migrating tickets"
Jean-Philippe Lang
Makes migration scripts load tickets in batches (#4011)....
r2809 TracTicket.find_each(:batch_size => 200) do |ticket|
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 print '.'
STDOUT.flush
i = Issue.new :project => @target_project,
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 :subject => encode(ticket.summary[0, limit_for(Issue, 'subject')]),
:description => convert_wiki_text(encode(ticket.description)),
:priority => PRIORITY_MAPPING[ticket.priority] || DEFAULT_PRIORITY,
:created_on => ticket.time
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 i.author = find_or_create_user(ticket.reporter)
i.category = issues_category_map[ticket.component] unless ticket.component.blank?
i.fixed_version = version_map[ticket.milestone] unless ticket.milestone.blank?
i.tracker = TRACKER_MAPPING[ticket.ticket_type] || DEFAULT_TRACKER
Jean-Philippe Lang
Default status per tracker (#5991)....
r13153 i.status = STATUS_MAPPING[ticket.status] || i.default_status
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 i.id = ticket.id unless Issue.exists?(ticket.id)
next unless Time.fake(ticket.changetime) { i.save }
TICKET_MAP[ticket.id] = i.id
migrated_tickets += 1
# Owner
Jean-Philippe Lang
Trac importer now migrates status changes....
r682 unless ticket.owner.blank?
i.assigned_to = find_or_create_user(ticket.owner, true)
Jean-Philippe Lang
Fixed: migrate_from_trac doesn't import timestamps of wiki and tickets (patch #882 by Andreas Neuhaus slightly edited)....
r1287 Time.fake(ticket.changetime) { i.save }
Jean-Philippe Lang
Trac importer now migrates status changes....
r682 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
# Comments and status/resolution changes
Jean-Philippe Lang
Renamed #changes association to #ticket_changes....
r9577 ticket.ticket_changes.group_by(&:time).each do |time, changeset|
Jean-Philippe Lang
Trac importer now migrates status changes....
r682 status_change = changeset.select {|change| change.field == 'status'}.first
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 resolution_change = changeset.select {|change| change.field == 'resolution'}.first
Jean-Philippe Lang
Trac importer now migrates status changes....
r682 comment_change = changeset.select {|change| change.field == 'comment'}.first
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer now migrates status changes....
r682 n = Journal.new :notes => (comment_change ? convert_wiki_text(encode(comment_change.newvalue)) : ''),
:created_on => time
n.user = find_or_create_user(changeset.first.author)
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 n.journalized = i
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 if status_change &&
Jean-Philippe Lang
Trac importer now migrates status changes....
r682 STATUS_MAPPING[status_change.oldvalue] &&
STATUS_MAPPING[status_change.newvalue] &&
(STATUS_MAPPING[status_change.oldvalue] != STATUS_MAPPING[status_change.newvalue])
n.details << JournalDetail.new(:property => 'attr',
:prop_key => 'status_id',
:old_value => STATUS_MAPPING[status_change.oldvalue].id,
:value => STATUS_MAPPING[status_change.newvalue].id)
end
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 if resolution_change
n.details << JournalDetail.new(:property => 'cf',
:prop_key => custom_field_map['resolution'].id,
:old_value => resolution_change.oldvalue,
:value => resolution_change.newvalue)
end
n.save unless n.details.empty? && n.notes.blank?
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 end
# Attachments
ticket.attachments.each do |attachment|
next unless attachment.exist?
Jean-Philippe Lang
Fixed Trac importer broken by r2670 (#3254)....
r2609 attachment.open {
a = Attachment.new :created_on => attachment.time
a.file = attachment
a.author = find_or_create_user(attachment.author)
a.container = i
a.description = attachment.description
migrated_ticket_attachments += 1 if a.save
}
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 end
# Custom fields
custom_values = ticket.customs.inject({}) do |h, custom|
if custom_field = custom_field_map[custom.name]
h[custom_field.id] = custom.value
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 migrated_custom_values += 1
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 end
h
end
if custom_field_map['resolution'] && !ticket.resolution.blank?
custom_values[custom_field_map['resolution'].id] = ticket.resolution
end
i.custom_field_values = custom_values
i.save_custom_field_values
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Use Postgresql's reset_pk_sequence in Trac importer to reset issue id sequence (#595)....
r1105 # update issue id sequence if needed (postgresql)
Issue.connection.reset_pk_sequence!(Issue.table_name) if Issue.connection.respond_to?('reset_pk_sequence!')
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 puts
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
# Wiki
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 print "Migrating wiki"
if wiki.save
Jean-Philippe Lang
Replaces find(:all) calls....
r10690 TracWikiPage.order('name, version').all.each do |page|
Jean-Philippe Lang
Trac importer fix:...
r1161 # Do not migrate Trac manual wiki pages
next if TRAC_WIKI_PAGES.include?(page.name)
wiki_edit_count += 1
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 print '.'
Jean-Philippe Lang
Trac importer improvements (by Mat Trudel):...
r918 STDOUT.flush
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 p = wiki.find_or_new_page(page.name)
p.content = WikiContent.new(:page => p) if p.new_record?
p.content.text = page.text
p.content.author = find_or_create_user(page.author) unless page.author.blank? || page.author == 'trac'
p.content.comments = page.comment
Jean-Philippe Lang
Fixed: migrate_from_trac doesn't import timestamps of wiki and tickets (patch #882 by Andreas Neuhaus slightly edited)....
r1287 Time.fake(page.time) { p.new_record? ? p.save : p.content.save }
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer fix:...
r1161 next if p.content.new_record?
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 migrated_wiki_edits += 1
Jean-Philippe Lang
Trac importer fix:...
r1161 # Attachments
page.attachments.each do |attachment|
next unless attachment.exist?
next if p.attachments.find_by_filename(attachment.filename.gsub(/^.*(\\|\/)/, '').gsub(/[^\w\.\-]/,'_')) #add only once per page
Jean-Philippe Lang
Same as fix as r2705 from Trac wiki pages attachments (#3291)....
r2620 attachment.open {
a = Attachment.new :created_on => attachment.time
a.file = attachment
a.author = find_or_create_user(attachment.author)
a.description = attachment.description
a.container = p
migrated_wiki_attachments += 1 if a.save
}
Jean-Philippe Lang
Trac importer fix:...
r1161 end
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 wiki.reload
wiki.pages.each do |page|
page.content.text = convert_wiki_text(page.content.text)
Jean-Philippe Lang
Fixed: migrate_from_trac doesn't import timestamps of wiki and tickets (patch #882 by Andreas Neuhaus slightly edited)....
r1287 Time.fake(page.content.updated_on) { page.content.save }
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
end
puts
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 puts
puts "Components: #{migrated_components}/#{TracComponent.count}"
puts "Milestones: #{migrated_milestones}/#{TracMilestone.count}"
puts "Tickets: #{migrated_tickets}/#{TracTicket.count}"
Jean-Philippe Lang
Trac importer fix:...
r1161 puts "Ticket files: #{migrated_ticket_attachments}/" + TracAttachment.count(:conditions => {:type => 'ticket'}).to_s
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 puts "Custom values: #{migrated_custom_values}/#{TracTicketCustom.count}"
Jean-Philippe Lang
Trac importer fix:...
r1161 puts "Wiki edits: #{migrated_wiki_edits}/#{wiki_edit_count}"
puts "Wiki files: #{migrated_wiki_attachments}/" + TracAttachment.count(:conditions => {:type => 'wiki'}).to_s
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def self.limit_for(klass, attribute)
klass.columns_hash[attribute.to_s].limit
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def self.encoding(charset)
Jean-Philippe Lang
Don't use iconv with ruby1.9 (#12787)....
r11210 @charset = charset
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 def self.set_trac_directory(path)
Jean-Philippe Lang
Trac importer:...
r933 @@trac_directory = path
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 raise "This directory doesn't exist!" unless File.directory?(path)
raise "#{trac_attachments_directory} doesn't exist!" unless File.directory?(trac_attachments_directory)
Jean-Philippe Lang
Trac importer:...
r933 @@trac_directory
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 rescue Exception => e
puts e
return false
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Trac importer: user can now choose between sqlite and sqlite3 adapter for Trac database....
r881
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def self.trac_directory
Jean-Philippe Lang
Trac importer:...
r933 @@trac_directory
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Trac importer: user can now choose between sqlite and sqlite3 adapter for Trac database....
r881
def self.set_trac_adapter(adapter)
Jean-Philippe Lang
Trac importer:...
r933 return false if adapter.blank?
Jean-Philippe Lang
Makes migrate_from_trac compatible with Rails3....
r9397 raise "Unknown adapter: #{adapter}!" unless %w(sqlite3 mysql postgresql).include?(adapter)
Jean-Philippe Lang
Trac importer:...
r933 # If adapter is sqlite or sqlite3, make sure that trac.db exists
Jean-Philippe Lang
Makes migrate_from_trac compatible with Rails3....
r9397 raise "#{trac_db_path} doesn't exist!" if %w(sqlite3).include?(adapter) && !File.exist?(trac_db_path)
Jean-Philippe Lang
Trac importer:...
r933 @@trac_adapter = adapter
rescue Exception => e
puts e
return false
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer:...
r933 def self.set_trac_db_host(host)
return nil if host.blank?
@@trac_db_host = host
end
def self.set_trac_db_port(port)
return nil if port.to_i == 0
@@trac_db_port = port.to_i
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer:...
r933 def self.set_trac_db_name(name)
return nil if name.blank?
@@trac_db_name = name
Jean-Philippe Lang
Trac importer: user can now choose between sqlite and sqlite3 adapter for Trac database....
r881 end
Jean-Philippe Lang
Trac importer:...
r933
def self.set_trac_db_username(username)
@@trac_db_username = username
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer:...
r933 def self.set_trac_db_password(password)
@@trac_db_password = password
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: support database schema for Trac migration (#757 by John Goerzen)....
r1181 def self.set_trac_db_schema(schema)
@@trac_db_schema = schema
end
mattr_reader :trac_directory, :trac_adapter, :trac_db_host, :trac_db_port, :trac_db_name, :trac_db_schema, :trac_db_username, :trac_db_password
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 def self.trac_db_path; "#{trac_directory}/db/trac.db" end
def self.trac_attachments_directory; "#{trac_directory}/attachments" end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def self.target_project_identifier(identifier)
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 project = Project.find_by_identifier(identifier)
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 if !project
# create the target project
project = Project.new :name => identifier.humanize,
Jean-Philippe Lang
Fixed: PostgreSQL issues_seq_id not updated when using Trac importer....
r1085 :description => ''
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 project.identifier = identifier
puts "Unable to create a project with identifier '#{identifier}'!" unless project.save
Jean-Philippe Lang
Trac importer: user can now choose between sqlite and sqlite3 adapter for Trac database....
r881 # enable issues and wiki for the created project
project.enabled_module_names = ['issue_tracking', 'wiki']
Jean-Philippe Lang
Trac importer:...
r1248 else
puts
puts "This project already exists in your Redmine database."
print "Are you sure you want to append data to this project ? [Y/n] "
Jean-Philippe Lang
Adds a few STDOUT.flush to migration scripts (#3675)....
r3214 STDOUT.flush
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 exit if STDIN.gets.match(/^n$/i)
Jean-Philippe Lang
Trac importer:...
r1248 end
project.trackers << TRACKER_BUG unless project.trackers.include?(TRACKER_BUG)
project.trackers << TRACKER_FEATURE unless project.trackers.include?(TRACKER_FEATURE)
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 @target_project = project.new_record? ? nil : project
Jean-Philippe Lang
Fixed: Trac importer creates duplicate wiki records (#4743)....
r3403 @target_project.reload
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer:...
r933 def self.connection_params
Jean-Philippe Lang
Makes migrate_from_trac compatible with Rails3....
r9397 if trac_adapter == 'sqlite3'
{:adapter => 'sqlite3',
Jean-Philippe Lang
Trac importer:...
r933 :database => trac_db_path}
else
{:adapter => trac_adapter,
:database => trac_db_name,
:host => trac_db_host,
:port => trac_db_port,
:username => trac_db_username,
Jean-Philippe Lang
Trac importer: support database schema for Trac migration (#757 by John Goerzen)....
r1181 :password => trac_db_password,
:schema_search_path => trac_db_schema
}
Jean-Philippe Lang
Trac importer:...
r933 end
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer:...
r933 def self.establish_connection
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 constants.each do |const|
klass = const_get(const)
next unless klass.respond_to? 'establish_connection'
Jean-Philippe Lang
Trac importer:...
r933 klass.establish_connection connection_params
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 def self.encode(text)
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 text.to_s.force_encoding(@charset).encode('UTF-8')
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 puts
Jean-Philippe Lang
Trac and Mantis importers: check that default configuration is loaded before processing....
r1207 if Redmine::DefaultData::Loader.no_data?
puts "Redmine configuration need to be loaded before importing data."
puts "Please, run this first:"
puts
puts " rake redmine:load_default_data RAILS_ENV=\"#{ENV['RAILS_ENV']}\""
exit
end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer:...
r933 puts "WARNING: a new project will be added to Redmine during this process."
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 print "Are you sure you want to continue ? [y/N] "
Jean-Philippe Lang
Adds a few STDOUT.flush to migration scripts (#3675)....
r3214 STDOUT.flush
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278 break unless STDIN.gets.match(/^y$/i)
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 puts
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681
def prompt(text, options = {}, &block)
default = options[:default] || ''
while true
print "#{text} [#{default}]: "
Jean-Philippe Lang
Adds a few STDOUT.flush to migration scripts (#3675)....
r3214 STDOUT.flush
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 value = STDIN.gets.chomp!
value = default if value.blank?
break if yield value
end
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer: support database schema for Trac migration (#757 by John Goerzen)....
r1181 DEFAULT_PORTS = {'mysql' => 3306, 'postgresql' => 5432}
Jean-Philippe Lang
Fixed that Trac importer was creating duplicate custom values (#2506)....
r2278
Jean-Philippe Lang
Trac importer fix:...
r1161 prompt('Trac directory') {|directory| TracMigrate.set_trac_directory directory.strip}
Jean-Philippe Lang
Makes migrate_from_trac compatible with Rails3....
r9397 prompt('Trac database adapter (sqlite3, mysql2, postgresql)', :default => 'sqlite3') {|adapter| TracMigrate.set_trac_adapter adapter}
unless %w(sqlite3).include?(TracMigrate.trac_adapter)
Jean-Philippe Lang
Trac importer:...
r933 prompt('Trac database host', :default => 'localhost') {|host| TracMigrate.set_trac_db_host host}
prompt('Trac database port', :default => DEFAULT_PORTS[TracMigrate.trac_adapter]) {|port| TracMigrate.set_trac_db_port port}
prompt('Trac database name') {|name| TracMigrate.set_trac_db_name name}
Jean-Philippe Lang
Trac importer: support database schema for Trac migration (#757 by John Goerzen)....
r1181 prompt('Trac database schema', :default => 'public') {|schema| TracMigrate.set_trac_db_schema schema}
Jean-Philippe Lang
Trac importer:...
r933 prompt('Trac database username') {|username| TracMigrate.set_trac_db_username username}
prompt('Trac database password') {|password| TracMigrate.set_trac_db_password password}
end
Jean-Philippe Lang
Trac importer: 'resolution' field imported with history as a custom field....
r683 prompt('Trac database encoding', :default => 'UTF-8') {|encoding| TracMigrate.encoding encoding}
Jean-Philippe Lang
Trac importer now checks the existence of trac.db and attachments directory before processing....
r681 prompt('Target project identifier') {|identifier| TracMigrate.target_project_identifier identifier}
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 puts
Toshi MARUYAMA
remove trailing white-spaces from lib/tasks/migrate_from_trac.rake...
r6954
Jean-Baptiste Barth
Ensure Tranc and Mantis importers don't reset global notification settings (#13989)....
r11565 old_notified_events = Setting.notified_events
Jean-Philippe Lang
Fixed that Mantis/Trac users are not imported because of password too short (#14590)....
r11933 old_password_min_length = Setting.password_min_length
Jean-Baptiste Barth
Ensure Tranc and Mantis importers don't reset global notification settings (#13989)....
r11565 begin
# Turn off email notifications temporarily
Setting.notified_events = []
Jean-Philippe Lang
Fixed that Mantis/Trac users are not imported because of password too short (#14590)....
r11933 Setting.password_min_length = 4
Jean-Baptiste Barth
Ensure Tranc and Mantis importers don't reset global notification settings (#13989)....
r11565 # Run the migration
TracMigrate.migrate
ensure
Jean-Philippe Lang
Fixed that Mantis/Trac users are not imported because of password too short (#14590)....
r11933 # Restore previous settings
Jean-Baptiste Barth
Ensure Tranc and Mantis importers don't reset global notification settings (#13989)....
r11565 Setting.notified_events = old_notified_events
Jean-Philippe Lang
Fixed that Mantis/Trac users are not imported because of password too short (#14590)....
r11933 Setting.password_min_length = old_password_min_length
Jean-Baptiste Barth
Ensure Tranc and Mantis importers don't reset global notification settings (#13989)....
r11565 end
Jean-Philippe Lang
Trac importer initial commit. The script migrates:...
r678 end
end