From: dklawren Date: Thu, 17 Jan 2019 20:38:15 +0000 (-0500) Subject: Bug 1509329 - Do not display revisions that have moved out of the bug, but note the... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1151f3c06d3b78609f6e9654e0707cc2399d631;p=thirdparty%2Fbugzilla.git Bug 1509329 - Do not display revisions that have moved out of the bug, but note the move in the bug history --- diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm index 8c204204e..cbca9ae28 100644 --- a/extensions/PhabBugz/lib/Feed.pm +++ b/extensions/PhabBugz/lib/Feed.pm @@ -184,9 +184,8 @@ sub feed_query { } else { my $phab_user = Bugzilla::User->new({name => PHAB_AUTOMATION_USER}); - $author - = Bugzilla::Extension::PhabBugz::User->new_from_query({ids => [$phab_user->id] - }); + $author = Bugzilla::Extension::PhabBugz::User->new_from_query( + {ids => [$phab_user->id]}); } # Load the revision from Phabricator @@ -370,7 +369,6 @@ sub process_revision_change { } } - my $log_message = sprintf( "REVISION CHANGE FOUND: D%d: %s | bug: %d | %s | %s", $revision->id, $revision->title, $revision->bug_id, @@ -489,7 +487,24 @@ sub process_revision_change { . $attachment->id . " for bug " . $attachment->bug_id); + my $moved_comment + = "Revision D" + . $revision->id + . " was moved to bug " + . $bug->id + . ". Setting attachment " + . $attachment->id + . " to obsolete."; $attachment->set_is_obsolete(1); + $attachment->bug->add_comment( + $moved_comment, + { + type => CMT_ATTACHMENT_UPDATED, + extra_data => $attachment->id, + is_markdown => (Bugzilla->params->{use_markdown} ? 1 : 0) + } + ); + $attachment->bug->update($timestamp); $attachment->update($timestamp); } diff --git a/extensions/PhabBugz/lib/WebService.pm b/extensions/PhabBugz/lib/WebService.pm index bca05d303..d6480a601 100644 --- a/extensions/PhabBugz/lib/WebService.pm +++ b/extensions/PhabBugz/lib/WebService.pm @@ -165,6 +165,10 @@ sub bug_revisions { my @revisions; foreach my $revision (@{$response->{result}{data}}) { + + # Skip if revision bug id was moved to a different bug + next if $revision->{fields}->{'bugzilla.bug-id'} ne $bug->id; + my $revision_obj = Bugzilla::Extension::PhabBugz::Revision->new($revision); my $revision_data = { id => 'D' . $revision_obj->id,