@@ 0,0 1,19 @@
+--- !ditz.rubyforge.org,2008-03-06/issue
+title: Add support in ditz for component owner
+desc: ""
+type: :feature
+component: trac to ditz
+release:
+reporter: Sean Russell <ser@ser1.net>
+status: :unstarted
+disposition:
+creation_time: 2010-01-27 13:24:08.081006 Z
+references: []
+
+id: 9618638bbe9059ffa431f5edc8d7b9c9a938dbab
+log_events:
+- - 2010-01-27 13:24:08.081643 Z
+ - Sean Russell <ser@ser1.net>
+ - created
+ - ""
+trac_id:
@@ 137,21 137,51 @@ EOS
# Syncs ditz issues -> Trac
def create_tickets( issues, trac )
- components = trac.query("ticket.component.getAll")
- milestones = trac.query("ticket.milestone.getAll")
+ maybe_create_milestones( trac )
+ maybe_create_components( trac )
+ new_tickets = []
issues.each do |t,i| # t will always be nil
- attrs = { "created_at" => i.creation_time,
+ tid = trac.tickets.create( i.title, i.desc, {
+ "created_at" => i.creation_time,
"type" => DTYPE_TTYPE[ i.type ],
"reporter" => i.reporter || "",
"milestone" => i.release || "",
"component" => i.component || "",
"status" => DSTATUS_TSTATUS[ i.status ] || "",
"resolution" => DISPO_RES[ i.disposition ] || ""
- }
- p attrs
- tid = trac.tickets.create( i.title, i.desc, attrs )
+ } )
+ new_tickets << trac.tickets.get( tid )
i.trac_id = tid
end
+ new_tickets
+ end
+
+ def maybe_create_components( trac )
+ components = trac.query("ticket.component.getAll")
+ @project.components.each do |component|
+ next if components.include? component.name
+ trac.query("ticket.component.create", component.name, {})
+ end
+ end
+
+ def maybe_create_milestones( trac )
+ milestones = trac.query("ticket.milestone.getAll")
+ @project.releases.each do |release|
+ next if milestones.include? release.name
+ desc = rel = ""
+ release.log_events.each do |ev|
+ case ev[2]
+ when "created"
+ desc = ev[3]
+ when "released"
+ rel = ev[0]
+ end
+ end
+ trac.query("ticket.milestone.create", release.name, {
+ "completed" => rel,
+ "description" => desc
+ })
+ end
end
@@ 225,6 255,10 @@ EOS
end
+ def update_tickets( pairs, trac )
+ end
+
+
def update_issues( pairs, trac )
pairs.each do |ticket, issue|
puts "Working on #{ticket.id}/#{issue.id[0,4]}"
@@ 317,12 351,22 @@ EOS
tickets = trac.tickets.get_all.values
changelogs = []
- pairs = util.pair(tickets)
- util.create_issues( pairs.find_all {|m| m[1] == nil} )
+ # TODO this is really inefficient. No need to re-update things that have
+ # already been updated, and we're re-pairing too much. The create methods
+ # could just pair in the method and return the pairs
+
+ # Existing ticket/issue matches
pairs = util.pair(tickets)
+
+ # Create and update any missing issues
+ util.create_issues( pairs.find_all {|m| m[1] == nil} )
+ pairs = util.pair(tickets) # re-match the pairs
util.update_issues( pairs.find_all {|m| m[0] != nil && m[1] != nil}, trac )
- util.create_tickets( pairs.find_all {|m| m[0] == nil}, trac )
- #issue.log "commented", config.user, comment
+
+ # Create and update any missing tickets
+ new_tickets = util.create_tickets( pairs.find_all {|m| m[0] == nil}, trac )
+ pairs = util.pair( tickets + new_tickets )
+ util.update_tickets( pairs.find_all {|m| m[0] != nil && m[1] != nil}, trac )
end
end
end