Skip to content

Commit

Permalink
Merge branch 'master' of github.com:brienw/trac2tracker
Browse files Browse the repository at this point in the history
Conflicts:
	trac2tracker.rb
  • Loading branch information
Brien Wankel committed May 7, 2013
2 parents d6a6d16 + e83bf3b commit 08946d6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.db
*.db
.idea
84 changes: 39 additions & 45 deletions trac2tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,38 @@
require 'sqlite3'
require 'pivotal-tracker'

trac_db = "trac.db"
default_user = "ezhou"
trac_db = 'trac.db'
default_user = 'ezhou'

pt_email = '[email protected]'
# pt_project_id = '784261' # CPF spt
pt_project_id = '821611' # CPF Test
pt_project_id = ENV['PIVOTAL_PROJECT_ID'] ? ENV['PIVOTAL_PROJECT_ID'] : '821611'

unless pt_email
print "Pivotal Email: "
pt_email = gets.chomp
end
if ENV['PIVOTAL_TOKEN']
PivotalTracker::Client.token = ENV['PIVOTAL_TOKEN']
else
unless pt_email
print 'Pivotal email: '
pt_email = gets.chomp
end

print "Pivotal Password: "
pt_password = STDIN.noecho(&:gets).chomp
puts
print 'Pivotal Password: '
pt_password = STDIN.noecho(&:gets).chomp
puts

unless pt_project_id
puts "\nPivotal Project ID: "
pt_project_id = gets.chomp
PivotalTracker::Client.token(pt_email, pt_password)
puts "Authenticated as #{pt_email}"
end

PivotalTracker::Client.token(pt_email, pt_password)
puts "Authenticated as #{pt_email}"

project = PivotalTracker::Project.find(pt_project_id)
if project
puts "Found project '#{project.name}'"
else
puts "You do not appear to have permission to manage this project"
puts 'You do not appear to have permission to manage this project'
end

db = SQLite3::Database.new( trac_db )
puts "Trac db loaded"
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')


memberships = (project.memberships.all).collect(&:name).map(&:downcase)
Expand All @@ -55,53 +52,50 @@

columns = nil

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

if columns.nil?
columns = row_array
next
end
row = {}
columns.each_with_index do |name,index|
columns.each_with_index do |name, index|
row[name.to_sym] = row_array[index]
end

if row[:severity].nil?
row[:severity] = "1"
end
if row[:status].nil?
row[:status] = "unscheduled"
row[:status] = 'unscheduled'
end
if row[:owner].nil?
row[:owner] = default_user
end

# translate statuses
if ( row[:status] == 'closed' && (['fixed', 'duplicate', 'wontfix', 'invalid', 'worksforme'].include? row[:resolution].chomp ))
row[:status] = 'accepted'
elsif ( row[:status] == 'closed' && (['readytotest', 'reviewfix'].include? row[:resolution] ) )
if row[:status] == 'closed' && %w(fixed duplicate wontfix invalid worksforme).include?(row[:resolution].chomp)
row[:status] = 'accepted'
elsif row[:status] == 'closed' && %w(readytotest reviewfix).include?(row[:resolution].chomp)
row[:status] = 'delivered'
elsif row[:status] == 'assigned'
row[:status] = 'unstarted'
elsif row[:status] == 'new'
row[:status] = 'unscheduled'
row[:status] = 'unscheduled'
elsif row[:status] == 'reopened'
row[:status] = 'rejected'
end

#translate types
row[:type] = case row[:type]
when 'defect'
'bug'
when 'enhancement'
'feature'
when 'roadmap'
'release'
when 'spec needed','task'
'chore'
else
row[:type]
end
when 'defect'
'bug'
when 'enhancement'
'feature'
when 'roadmap'
'release'
when 'spec needed', 'task'
'chore'
else
row[:type]
end

if row[:type] == 'release' && row[:status] == 'delivered'
row[:status] = 'accepted'
Expand All @@ -126,7 +120,7 @@
end
accepted_at = Time.at(row[:changetime]) if row[:status] == 'accepted'
# bugs and releases can't have estimate
estimate = nil if ['bug', 'release', 'chore'].include? story_type
estimate = nil if %w(bug release chore).include? story_type

# update progress bar with new ticket id
ticket_progress.title = "Ticket #{id}"
Expand Down Expand Up @@ -169,4 +163,4 @@
end
puts "\nErrors: #{errors}" if errors > 0
puts "Ticket IDs: " + error_ids.join(',') if error_ids.length > 0
puts "failed adding comments to: " + comment_failures.join(',') if comment_failures.length > 0
puts "failed adding comments to: " + comment_failures.join(',') if comment_failures.length > 0

0 comments on commit 08946d6

Please sign in to comment.