Do not fetch commit message for ref deletions

When triggering an event for a ref deletion, avoid asking JGit for
the commit message because the relevant object id is zero and
would generate a missing unknown error.

Triggering issue tracker events for refs deletion makes perfect sense
and can be detected by actions with new revision being the zero object
id. The issue id can still be extracted from the last commit message of
the change before the deletion.

Bug: Issue 6265
Change-Id: Ic25b400b2688b2fb4bd35a504e3787c803df7a15
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
index 2ea5198..16519de 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
@@ -21,6 +21,7 @@
 import com.google.gerrit.server.data.ApprovalAttribute;
 import com.google.gerrit.server.data.ChangeAttribute;
 import com.google.gerrit.server.data.PatchSetAttribute;
+import com.google.gerrit.server.data.RefUpdateAttribute;
 import com.google.gerrit.server.events.ChangeAbandonedEvent;
 import com.google.gerrit.server.events.ChangeEvent;
 import com.google.gerrit.server.events.ChangeMergedEvent;
@@ -35,6 +36,7 @@
 import com.googlesource.gerrit.plugins.its.base.workflow.Property;
 import java.util.Map;
 import java.util.Set;
+import org.eclipse.jgit.lib.ObjectId;
 
 /** Extractor to translate an {@link ChangeEvent} to {@link Property Properties}. */
 public class PropertyExtractor {
@@ -110,8 +112,12 @@
       common.addAll(propertyAttributeExtractor.extractFrom(event.submitter.get(), "submitter"));
     }
     common.addAll(propertyAttributeExtractor.extractFrom(event.refUpdate.get()));
-    return issueExtractor.getIssueIds(
-        event.getProjectNameKey().get(), event.refUpdate.get().newRev);
+    RefUpdateAttribute refUpdateEvent = event.refUpdate.get();
+    String commitId =
+        (refUpdateEvent.newRev.equals(ObjectId.zeroId().name())
+            ? refUpdateEvent.oldRev
+            : refUpdateEvent.newRev);
+    return issueExtractor.getIssueIds(event.getProjectNameKey().get(), commitId);
   }
 
   private Map<String, Set<String>> extractFrom(PatchSetCreatedEvent event, Set<Property> common) {