Skip to content

Commit

Permalink
Roadmap tickets are now imported as feature stories
Browse files Browse the repository at this point in the history
  • Loading branch information
Brien Wankel committed May 17, 2013
1 parent c4a2e69 commit c4870e1
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions trac2tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require 'pivotal-tracker'

trac_db = 'trac.db'
default_user = 'ezhou'
default_user = 'Elaine Zhou'

pt_project_id = ENV['PIVOTAL_PROJECT_ID'] ? ENV['PIVOTAL_PROJECT_ID'] : '821611'

Expand Down Expand Up @@ -35,13 +35,11 @@
end



usernames = []
memberships = (project.memberships.all).collect(&:name).map(&:downcase)
# TODO: verify memberships
memberships.each do |member|
(first, last) = member.split
usernames << first[0].downcase + last.downcase
# create a simple dictionary to match trac usernames to pivotal membership names
membership_mapping = {}
project.memberships.all.each do |member|
username = member.email.split('@').first
membership_mapping[username] = member.name
end

story = nil
Expand All @@ -53,11 +51,11 @@
db = SQLite3::Database.new(trac_db)
puts 'Trac db loaded'

ticket_count = db.get_first_value('select count(*) from ticket')
ticket_count = db.get_first_value('select count(*) from ticket where id < 4650')
ticket_progress = ProgressBar.create(:title => 'Tickets: ',
:format => '%t %c/%C (%p%) |%b>>%i|', :total => ticket_count.to_i)

db.execute2('select * from ticket order by id desc') do |row_array|
db.execute2('select * from ticket where id < 4650 order by id desc') do |row_array|

if columns.nil?
columns = row_array
Expand All @@ -68,9 +66,6 @@
row[name.to_sym] = row_array[index]
end

row[:status] ||= 'unscheduled'
row[:owner] ||= default_user

# translate statuses
if row[:status] == 'closed' && %w(fixed duplicate wontfix invalid worksforme).include?(row[:resolution].chomp)
row[:status] = 'accepted'
Expand All @@ -88,7 +83,7 @@
row[:type] = case row[:type]
when 'defect'; 'bug'
when 'enhancement'; 'feature'
when 'roadmap'; 'release'
when 'roadmap'; 'feature'
when 'spec needed', 'task'; 'chore'
else row[:type]
end
Expand All @@ -100,20 +95,22 @@
row[:status] = 'accepted'
end

row[:status] ||= 'unscheduled'

id = row[:id]
story = row[:summary]
labels = row[:milestone]
story_type = row[:type]
estimate = '1' #Why are we defaulting to the string '1', should it be nil or numeric? Maybe only set it if the task is assigned?
current_state = row[:status]
requested_by = row[:reporter]
owner = row[:owner]
description = row[:description]
requested_by = membership_mapping[row[:reporter]] || default_user
owner = membership_mapping[row[:owner]] || nil

unless memberships.include? requested_by.downcase
# project.memberships.create(name: requested_by)
memberships << requested_by.downcase
# only keep owner for open/assigned stories
if !['unstarted','rejected'].include? current_state
owner = nil
end
description = row[:description]

accepted_at = Time.at(row[:changetime]) if row[:status] == 'accepted'
# bugs and releases can't have estimate
Expand Down Expand Up @@ -144,8 +141,8 @@
current_state: current_state,
created_at: Time.at(row[:time]),
accepted_at: accepted_at,
# requested_by: requested_by,
# owner: owner,
requested_by: requested_by,
owned_by: owner,
description: description.chomp + "\n[trac#{id}] Imported from trac, original id #{id}"
)

Expand Down

0 comments on commit c4870e1

Please sign in to comment.