# HG changeset patch # User Sean Russell # Date 1264568294 18000 # Tue Jan 26 23:58:14 2010 -0500 # Node ID 7566af7149bb583d0e8091210da103230497fd03 # Parent b8cc495c07c212da73a746ae21b0fd5905c7b13a Closes 7999b, support for components diff --git a/.ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml b/.ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml --- a/.ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml +++ b/.ditz/issue-7999b8b298dd44690f44349da9a8dd88bbe4d9a3.yaml @@ -3,10 +3,10 @@ desc: "" type: :feature component: ditz-trac -release: +release: "2010.1" reporter: Sean Russell -status: :unstarted -disposition: +status: :closed +disposition: :fixed creation_time: 2010-01-27 04:10:52.296768 Z references: [] @@ -16,4 +16,16 @@ - Sean Russell - created - "" +- - 2010-01-27 04:53:06.316893 Z + - Sean Russell + - changed status from unstarted to in_progress + - "" +- - 2010-01-27 04:53:20.036864 Z + - Sean Russell + - assigned to release 2010.1 from unassigned + - "" +- - 2010-01-27 04:53:29.108848 Z + - Sean Russell + - closed with disposition fixed + - "" trac_id: diff --git a/.ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml b/.ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml --- a/.ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml +++ b/.ditz/issue-837b4acc500d7835adfecfc75b948d57b6e2337e.yaml @@ -5,8 +5,8 @@ component: ditz-trac release: reporter: Sean Russell -status: :unstarted -disposition: +status: :closed +disposition: :wontfix creation_time: 2010-01-27 04:11:12.204749 Z references: [] @@ -16,4 +16,10 @@ - Sean Russell - created - "" +- - 2010-01-27 04:54:09.568815 Z + - Sean Russell + - 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: diff --git a/.ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml b/.ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml new file mode 100644 --- /dev/null +++ b/.ditz/issue-8f7f150d0c575b55bd15bbb5bba4b7285ff7e942.yaml @@ -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 +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 + - created + - "" +trac_id: diff --git a/.ditz/project.yaml b/.ditz/project.yaml --- a/.ditz/project.yaml +++ b/.ditz/project.yaml @@ -8,5 +8,13 @@ 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 + - created + - "" diff --git a/trac-sync.rb b/trac-sync.rb --- a/trac-sync.rb +++ b/trac-sync.rb @@ -30,7 +30,6 @@ " 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 @@

Trac Synchronization

- - - - @@ -141,7 +136,9 @@ # 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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
Trac ID:<%= issue.trac_id %>
Trac URL: <%= config.trac_sync_url %>