From 0db61205318eb29323816da27e7883668d58de55 Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Mon, 6 May 2013 18:06:38 -0700 Subject: [PATCH 1/5] adding .idea folder to gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3997bea..2b0bcab 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.db \ No newline at end of file +*.db +.idea \ No newline at end of file From 7c036dfd2689fc71f649ee63c563fae6b6d8b86d Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Mon, 6 May 2013 18:28:06 -0700 Subject: [PATCH 2/5] use a token instead of u/p and clean up double quoted strings --- trac2tracker.rb | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/trac2tracker.rb b/trac2tracker.rb index a64999b..9dd09b3 100755 --- a/trac2tracker.rb +++ b/trac2tracker.rb @@ -6,41 +6,26 @@ require 'sqlite3' require 'pivotal-tracker' -trac_db = "trac.db" -default_user = "ezhou" +trac_db = 'trac.db' +default_user = 'ezhou' -pt_email = 'brien@reebosak.net' # pt_project_id = '784261' # CPF spt pt_project_id = '820749' # CPF Test +#pt_project_id = '820865' # matt's CPF Test -unless pt_email - print "Pivotal Email: " - pt_email = gets.chomp -end - -print "Pivotal Password: " -pt_password = STDIN.noecho(&:gets).chomp -puts - -unless pt_project_id - puts "\nPivotal Project ID: " - pt_project_id = gets.chomp -end - -PivotalTracker::Client.token(pt_email, pt_password) -puts "Authenticated as #{pt_email}" +PivotalTracker::Client.token('af71b91e9102585283e85b0a790d0971') 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" +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) @@ -49,12 +34,12 @@ story = nil errors = 0 -ticket_progress = ProgressBar.create(:title => "Tickets: ", - :format => "%t %c/%C (%p%) |%b>>%i|", :total => ticket_count.to_i) +ticket_progress = ProgressBar.create(:title => 'Tickets: ', + :format => '%t %c/%C (%p%) |%b>>%i|', :total => ticket_count.to_i) 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 From 7df7c22eed670b129697d466d86b482e9d0b16e1 Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Mon, 6 May 2013 18:48:05 -0700 Subject: [PATCH 3/5] take token from env --- trac2tracker.rb | 57 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/trac2tracker.rb b/trac2tracker.rb index 9dd09b3..f459b35 100755 --- a/trac2tracker.rb +++ b/trac2tracker.rb @@ -13,7 +13,26 @@ pt_project_id = '820749' # CPF Test #pt_project_id = '820865' # matt's CPF Test -PivotalTracker::Client.token('af71b91e9102585283e85b0a790d0971') +unless ENV['PIVOTAL_TOKEN'] + unless pt_email + print "Pivotal token: " + pt_email = gets.chomp + end + + print "Pivotal Password: " + pt_password = STDIN.noecho(&:gets).chomp + puts + + unless pt_project_id + puts "\nPivotal Project ID: " + pt_project_id = gets.chomp + end + + PivotalTracker::Client.token(pt_email, pt_password) + puts "Authenticated as #{pt_email}" +else + PivotalTracker::Client.token = ENV['PIVOTAL_TOKEN'] +end project = PivotalTracker::Project.find(pt_project_id) if project @@ -22,7 +41,7 @@ puts 'You do not appear to have permission to manage this project' end -db = SQLite3::Database.new( trac_db ) +db = SQLite3::Database.new(trac_db) puts 'Trac db loaded' ticket_count = db.get_first_value('select count(*) from ticket') @@ -35,7 +54,7 @@ story = nil errors = 0 ticket_progress = ProgressBar.create(:title => 'Tickets: ', - :format => '%t %c/%C (%p%) |%b>>%i|', :total => ticket_count.to_i) + :format => '%t %c/%C (%p%) |%b>>%i|', :total => ticket_count.to_i) columns = nil @@ -46,7 +65,7 @@ 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 @@ -61,31 +80,31 @@ 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' && (['fixed', 'duplicate', 'wontfix', 'invalid', 'worksforme'].include? row[:resolution].chomp)) + row[:status] = 'accepted' + elsif (row[:status] == 'closed' && (['readytotest', 'reviewfix'].include? row[:resolution])) 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' From 133a0aaa7a0081d7f2d0ed4033c02cfef9d5f00c Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Mon, 6 May 2013 18:55:53 -0700 Subject: [PATCH 4/5] fixing the fallback u/p case --- trac2tracker.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/trac2tracker.rb b/trac2tracker.rb index f459b35..0e3bd0b 100755 --- a/trac2tracker.rb +++ b/trac2tracker.rb @@ -12,14 +12,15 @@ # pt_project_id = '784261' # CPF spt pt_project_id = '820749' # CPF Test #pt_project_id = '820865' # matt's CPF Test +pt_email = 'brien@reebosak.net' unless ENV['PIVOTAL_TOKEN'] unless pt_email - print "Pivotal token: " + print "Pivotal email: " pt_email = gets.chomp end - print "Pivotal Password: " + print 'Pivotal Password: ' pt_password = STDIN.noecho(&:gets).chomp puts @@ -70,10 +71,10 @@ end if row[:severity].nil? - row[:severity] = "1" + row[:severity] = '1' end if row[:status].nil? - row[:status] = "unscheduled" + row[:status] = 'unscheduled' end if row[:owner].nil? row[:owner] = default_user From e83bf3bb1f55e1027026b0f7b8862c3af8ba0b9e Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Mon, 6 May 2013 19:26:05 -0700 Subject: [PATCH 5/5] satisfying the wisdom of rubymine --- trac2tracker.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/trac2tracker.rb b/trac2tracker.rb index 0e3bd0b..4d4db42 100755 --- a/trac2tracker.rb +++ b/trac2tracker.rb @@ -16,7 +16,7 @@ unless ENV['PIVOTAL_TOKEN'] unless pt_email - print "Pivotal email: " + print 'Pivotal email: ' pt_email = gets.chomp end @@ -70,9 +70,6 @@ row[name.to_sym] = row_array[index] end - if row[:severity].nil? - row[:severity] = '1' - end if row[:status].nil? row[:status] = 'unscheduled' end @@ -81,9 +78,9 @@ end # translate statuses - if (row[:status] == 'closed' && (['fixed', 'duplicate', 'wontfix', 'invalid', 'worksforme'].include? row[:resolution].chomp)) + if row[:status] == 'closed' && %w(fixed duplicate wontfix invalid worksforme).include?(row[:resolution].chomp) row[:status] = 'accepted' - elsif (row[:status] == 'closed' && (['readytotest', 'reviewfix'].include? row[:resolution])) + elsif row[:status] == 'closed' && %w(readytotest reviewfix).include?(row[:resolution].chomp) row[:status] = 'delivered' elsif row[:status] == 'assigned' row[:status] = 'unstarted' @@ -130,7 +127,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 begin story = project.stories.create(