diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-05-11 15:05:20 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-05-11 15:05:20 +0200 |
commit | bfa42fbedcff9ec55fbbbdcb0311e7bf0955763c (patch) | |
tree | 03b7bfa57f2a5ca10862ff414e21838f575b9525 | |
parent | e9ab86a49d81c6194dc62db3236cdf4d3380b3ee (diff) | |
download | bugzilla-bfa42fbedcff9ec55fbbbdcb0311e7bf0955763c.tar.gz bugzilla-bfa42fbedcff9ec55fbbbdcb0311e7bf0955763c.tar.xz |
Flyspray: Create comments for duplicate bugs
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | Bugzilla/Migrate/Flyspray.pm | 32 |
1 files 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}; } } |