]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1509329 - Do not display revisions that have moved out of the bug, but note the...
authordklawren <dklawren@users.noreply.github.com>
Thu, 17 Jan 2019 20:38:15 +0000 (15:38 -0500)
committerGitHub <noreply@github.com>
Thu, 17 Jan 2019 20:38:15 +0000 (15:38 -0500)
extensions/PhabBugz/lib/Feed.pm
extensions/PhabBugz/lib/WebService.pm

index 8c204204e6df33755318c1bdc02d6782c86a121b..cbca9ae28a36222b081a1f2e99a7df611e0064d5 100644 (file)
@@ -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);
   }
 
index bca05d303459a10d19bed90b0767a5872cb3fc8f..d6480a6010480981595a8092cb3c69660f56bc6f 100644 (file)
@@ -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,