Skip to content

Commit

Permalink
Many changes and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Brien Wankel committed May 7, 2013
1 parent d1c513b commit d6a6d16
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .pryrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
Pry.commands.alias_command 'exit', 'exit-program'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'pivotal-tracker'
gem 'pivotal-tracker', :path => '~/dev/pivotal-tracker'
gem 'sqlite3'
gem 'ruby-progressbar'
gem 'pry'
Expand Down
24 changes: 15 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
PATH
remote: ~/dev/pivotal-tracker
specs:
pivotal-tracker (0.5.10)
builder
builder
crack
happymapper (>= 0.3.2)
nokogiri (>= 1.4.3)
nokogiri (>= 1.5.5)
nokogiri-happymapper (>= 0.5.4)
rest-client (~> 1.6.0)
rest-client (~> 1.6.0)

GEM
remote: https://rubygems.org/
specs:
Expand All @@ -19,14 +33,6 @@ GEM
nokogiri (1.5.9)
nokogiri-happymapper (0.5.7)
nokogiri (~> 1.5)
pivotal-tracker (0.5.10)
builder
crack
happymapper (>= 0.3.2)
nokogiri (>= 1.4.3)
nokogiri (>= 1.5.5)
nokogiri-happymapper (>= 0.5.4)
rest-client (~> 1.6.0)
pry (0.9.12.1)
coderay (~> 1.0.5)
method_source (~> 0.8)
Expand All @@ -44,7 +50,7 @@ PLATFORMS
ruby

DEPENDENCIES
pivotal-tracker
pivotal-tracker!
pry
pry-debugger
ruby-progressbar
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
trac2tracker
============

A simple script to import a Trac sqlite database into a Pivotal Tracker project
A simple ruby script to import a Trac sqlite database into a Pivotal Tracker project
38 changes: 24 additions & 14 deletions trac2tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

pt_email = '[email protected]'
# pt_project_id = '784261' # CPF spt
pt_project_id = '820749' # CPF Test
pt_project_id = '821611' # CPF Test

unless pt_email
print "Pivotal Email: "
Expand Down Expand Up @@ -46,9 +46,10 @@
memberships = (project.memberships.all).collect(&:name).map(&:downcase)
# TODO: verify memberships


story = nil
errors = 0
error_ids = []
comment_failures = []
ticket_progress = ProgressBar.create(:title => "Tickets: ",
:format => "%t %c/%C (%p%) |%b>>%i|", :total => ticket_count.to_i)

Expand Down Expand Up @@ -127,6 +128,8 @@
# bugs and releases can't have estimate
estimate = nil if ['bug', 'release', 'chore'].include? story_type

# update progress bar with new ticket id
ticket_progress.title = "Ticket #{id}"
begin
story = project.stories.create(
name: story,
Expand All @@ -140,23 +143,30 @@
# owner: owner,
description: description.chomp + "\n[trac#{id}] Imported from trac, original id #{id}"
)
rescue
puts $!.backtrace
puts "Ticket: #{id}"
binding.pry
end
# # migrate comments
# db.execute(query = 'select newvalue from ticket_change where field=="comment" and newvalue != \'\' and ticket=' + id.to_s + ' and newvalue !=' + id.to_s) do |comment|
# story.notes.create(:text => comment[0]) unless comment[0].empty?
# end

if story.errors.count > 0
puts "Failed on ticket #{id}"
puts story.errors
binding.pry
errors = errors + 1
error_ids << id
else
ticket_progress.title = "Ticket #{id}"
# migrate comments
begin
db.execute(query = 'select newvalue from ticket_change where field=="comment" and newvalue != \'\' and ticket=' + id.to_s + ' and newvalue !=' + id.to_s) do |comment|
story.notes.create(:text => comment[0]) unless comment[0].empty?
end
rescue
puts "failed adding comments to ticket #{id}"
comment_failures << id
end
ticket_progress.increment
end
rescue
# puts $!.backtrace
puts "Failed on ticket: #{id}"
end

end
puts "Errors: #{errors}"
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

0 comments on commit d6a6d16

Please sign in to comment.