Closes 7999b, support for components
M .ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml +15 -3
@@ 3,10 3,10 @@ title: Add support for components
 desc: ""
 type: :feature
 component: ditz-trac
-release: 
+release: "2010.1"
 reporter: Sean Russell <ser@ser1.net>
-status: :unstarted
-disposition: 
+status: :closed
+disposition: :fixed
 creation_time: 2010-01-27 04:10:52.296768 Z
 references: []
 

          
@@ 16,4 16,16 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - created
   - ""
+- - 2010-01-27 04:53:06.316893 Z
+  - Sean Russell <ser@ser1.net>
+  - changed status from unstarted to in_progress
+  - ""
+- - 2010-01-27 04:53:20.036864 Z
+  - Sean Russell <ser@ser1.net>
+  - assigned to release 2010.1 from unassigned
+  - ""
+- - 2010-01-27 04:53:29.108848 Z
+  - Sean Russell <ser@ser1.net>
+  - closed with disposition fixed
+  - ""
 trac_id: 

          
M .ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml +8 -2
@@ 5,8 5,8 @@ type: :bugfix
 component: ditz-trac
 release: 
 reporter: Sean Russell <ser@ser1.net>
-status: :unstarted
-disposition: 
+status: :closed
+disposition: :wontfix
 creation_time: 2010-01-27 04:11:12.204749 Z
 references: []
 

          
@@ 16,4 16,10 @@ log_events:
   - Sean Russell <ser@ser1.net>
   - created
   - ""
+- - 2010-01-27 04:54:09.568815 Z
+  - Sean Russell <ser@ser1.net>
+  - closed with disposition wontfix
+  - |-
+    Duh.  Ditz already supports this -- put the .ditz-config in the project
+    directory, and it overrides the global one.
 trac_id: 

          
A => .ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml +21 -0
@@ 0,0 1,21 @@ 
+--- !ditz.rubyforge.org,2008-03-06/issue 
+title: Support translation between trac and ditz IDs
+desc: |-
+  Global replace in comments and description to replace Trac ID
+  references with ditz ID references when syncing.
+type: :feature
+component: ditz-trac
+release: 
+reporter: Sean Russell <ser@ser1.net>
+status: :unstarted
+disposition: 
+creation_time: 2010-01-27 04:14:45.464896 Z
+references: []
+
+id: 8f7f150d0c575b55bd15bbb5bba4b7285ff7e942
+log_events: 
+- - 2010-01-27 04:14:45.465530 Z
+  - Sean Russell <ser@ser1.net>
+  - created
+  - ""
+trac_id: 

          
M .ditz/project.yaml +10 -2
@@ 8,5 8,13 @@ components:
   name: ditz to trac
 - !ditz.rubyforge.org,2008-03-06/component 
   name: trac to ditz
-releases: []
-
+releases: 
+- !ditz.rubyforge.org,2008-03-06/release 
+  name: "2010.1"
+  status: :unreleased
+  release_time: 
+  log_events: 
+  - - 2010-01-27 04:32:11.788699 Z
+    - Sean Russell <ser@ser1.net>
+    - created
+    - ""

          
M trac-sync.rb +39 -24
@@ 30,7 30,6 @@ module Ditz
       " Trac ID: #{issue.trac_id || 'none'}\n"
     end
     add_to_view :issue_details do |issue, config|
-      "Trac ID: #{issue.trac_id || 'none'}\n"+
       "Trac URL: #{config.trac_sync_url || 'none'}\n"
     end
   end

          
@@ 53,10 52,6 @@ EOS
 <h2>Trac Synchronization</h2>
 <table>
   <tr>
-    <td class='attrname'>Trac ID:</td>
-    <td class='attrval'><%= issue.trac_id %></td>
-  </tr>
-  <tr>
     <td class='attrname'>Trac URL:</td>
     <td class='attrval'><%= config.trac_sync_url %></td>
   </tr>

          
@@ 141,7 136,9 @@ EOS
 
 
     # Syncs ditz issues -> Trac
-    def create_tickets( issues )
+    def create_tickets( issues, trac )
+      issues.each do |t,i| # t will always be nil
+      end
     end
 
 

          
@@ 150,12 147,8 @@ EOS
       tickets.each do |t,i|   # i will always be nil
         # trac4r doesn't yet support resolution
         resolution = t.status == "closed" ? :fixed : nil
-        release = @project.releases.find { |r| r.name == t.milestone }
-        unless release 
-          puts "Creating release #{t.milestone}"
-          release = Ditz::Release.create({:name=>t.milestone}, [@config, @project])
-          @project.add_release(release)
-        end
+        maybe_create_release( t.milestone )
+        maybe_create_component( t.component )
 
         if release.status == :released
           puts "Orphaned ticket ##{t.id}: milestone #{t.milestone} already released!"

          
@@ 181,7 174,7 @@ EOS
     end
 
 
-    def change_status status, issue
+    def change_status(status, issue)
       if issue.status != status
         old_status = issue.status
         issue.status = status

          
@@ 190,6 183,23 @@ EOS
       nil
     end
 
+    def maybe_create_release( milestone )
+        release = @project.releases.find { |r| r.name == milestone }
+        unless release 
+          puts "Creating release #{milestone}"
+          release = Ditz::Release.create({:name=>milestone}, [@config, @project])
+          @project.add_release(release)
+        end
+    end
+
+    def maybe_create_component( comp )
+        component = @project.components.find { |r| r.name == comp }
+        unless component 
+          puts "Creating component #{comp}"
+          component = Ditz::Component.create({:name=>comp}, [@config, @project])
+          @project.add_component(component)
+        end
+    end
 
     def group_by_time(changelog)
       rv = {}

          
@@ 223,29 233,34 @@ EOS
               when "comment"
                 comment = new_change[2]
               when "description"
-                if new_change[3] != issue.description
+                if new_change[4] != issue.description
                   whats << "edited description"
-                  issue.desc = new_change[3]
+                  issue.desc = new_change[4]
                 end
               when "milestone"
-                if new_change[3] != issue.release
-                  whats << "assigned to release #{new_change[3]} from #{issue.release || 'unassigned'}"
-                  issue.release = new_change[3]
+                if new_change[4] != issue.release
+                  whats << "assigned to release #{new_change[4]} from #{issue.release || 'unassigned'}"
+                  maybe_create_release( new_change[4] )
+                  issue.release = new_change[4]
                 end
               when "owner"
                 whats << change_status( :in_progress, issue )
               when "resolution"
                 RES_DISPO
-                issue.disposition = RES_DISPO[ new_change[3] ]
+                issue.disposition = RES_DISPO[ new_change[4] ]
               when "status"
-                whats << change_status( TSTATUS_DSTATUS[ new_change[3] ], issue )
+                whats << change_status( TSTATUS_DSTATUS[ new_change[4] ], issue )
               when "type"
-                new_t = TTYPE_DTYPE[ new_change[3] ]
+                new_t = TTYPE_DTYPE[ new_change[4] ]
                 whats << "type changed to #{new_t} from #{issue.type}"
                 issue.type = new_t
+              when "component"
+                new_c = new_change[4]
+                whats << "component changed to #{new_t} from #{issue.component}"
+                maybe_create_component( new_change[4] )
+                issue.component = new_t
 
-              when "attachment", "cc", "component", "os", "priority", 
-                "severity", "version"
+              when "attachment", "cc", "os", "priority", "severity", "version"
                 # NOOP
               else
                 # NOOP

          
@@ 293,7 308,7 @@ EOS
       util.create_issues( pairs.find_all {|m| m[1] == nil} )
       pairs = util.pair(tickets)
       util.update_issues( pairs.find_all {|m| m[0] != nil && m[1] != nil}, trac )
-      #util.create_tickets( pairs.find_all {|m| m[0] == nil} )
+      util.create_tickets( pairs.find_all {|m| m[0] == nil}, trac )
       #issue.log "commented", config.user, comment
     end
   end