-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:brienw/trac2tracker
Conflicts: trac2tracker.rb
- Loading branch information
Showing
2 changed files
with
41 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
*.db | ||
*.db | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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' | ||
|
@@ -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}" | ||
|
@@ -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 |