From bfa42fbedcff9ec55fbbbdcb0311e7bf0955763c Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 11 May 2018 15:05:20 +0200 Subject: Flyspray: Create comments for duplicate bugs Signed-off-by: Florian Pritz --- Bugzilla/Migrate/Flyspray.pm | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/Bugzilla/Migrate/Flyspray.pm b/Bugzilla/Migrate/Flyspray.pm index 9598e01f4..ff2143665 100644 --- a/Bugzilla/Migrate/Flyspray.pm +++ b/Bugzilla/Migrate/Flyspray.pm @@ -401,7 +401,26 @@ sub _read_bugs { }; if ($self->translate_value('resolution', $history->{resolution_name} // "") eq "DUPLICATE") { if ($self->translate_value('resolution', $bug->{resolution} // "") eq "DUPLICATE" and $closure_comment =~ m/FS#(\d+)/) { - $self->{dupes}->{$row->{task_id}} = int($1); + push @{$self->{dupes}}, { + dupe_of => int($1), + dupe => $row->{task_id}, + who => $self->_get_username($history->{user_id}), + bug_when => $self->parse_date($history->{event_date}), + }; + + push @{$bug->{comments}}, { + type => CMT_DUPE_OF, + extra_data => int($1), + who => $self->_get_username($history->{user_id}), + bug_when => $self->parse_date($history->{event_date}), + }; + + push @{$self->{bug_map}->{int($1)}->{comments}}, { + type => CMT_HAS_DUPE, + extra_data => $row->{task_id}, + who => $self->_get_username($history->{user_id}), + bug_when => $self->parse_date($history->{event_date}), + } if defined $self->{bug_map}->{int($1)}; } } } elsif ($history->{event_type} == 3) { @@ -452,6 +471,8 @@ sub _read_bugs { #die if $attachment->{date_added} == 1110715864; } + $self->{bug_map}->{$bug->{bug_id}} = $bug; + push @result, $bug; } @@ -520,10 +541,11 @@ sub after_read { sub after_insert { my ($self) = @_; - for my $dupe (keys %{$self->{dupes}}) { - my $dupe_of = $self->{dupes}->{$dupe}; - my $bug = Bugzilla::Bug->new($dupe_of); - $self->{dbh}->do("INSERT INTO duplicates (dupe_of, dupe) VALUES (?, ?)", undef, $dupe_of, $dupe) unless defined $bug->{error}; + $self->debug("Marking duplicate bugs"); + $self->debug($self->{dupes}, 3); + for my $entry (@{$self->{dupes}}) { + my $dupeOf_bug = Bugzilla::Bug->new($entry->{dupe_of}); + $self->{dbh}->do("INSERT INTO duplicates (dupe_of, dupe) VALUES (?, ?)", undef, $entry->{dupe_of}, $entry->{dupe}) unless defined $dupeOf_bug->{error}; } } -- cgit v1.2.3-24-g4f1b