Log the incoming git refs events for replication

Display on the pull_replication_log all the git-ref event
details for the events received and selected by the pull-replication
plugin for being fired to the remotes.

Preparatory work for helping with the troubleshooting of
errors in processing the incoming events.

Bug: Issue 15608
Change-Id: If9cf8041ed261d42f849e8e80c14266ceae70e68
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
index 61f2a64..fdfe3fd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
@@ -134,6 +134,13 @@
   @Override
   public void onGitReferenceUpdated(GitReferenceUpdatedListener.Event event) {
     if (isRefToBeReplicated(event.getRefName())) {
+      repLog.info(
+          "Ref event received: {} on project {}:{} - {} => {}",
+          refUpdateType(event),
+          event.getProjectName(),
+          event.getRefName(),
+          event.getOldObjectId(),
+          event.getNewObjectId());
       fire(event.getProjectName(), ObjectId.fromString(event.getNewObjectId()), event.getRefName());
     }
   }
@@ -148,6 +155,17 @@
                 source.getApis().forEach(apiUrl -> source.scheduleDeleteProject(apiUrl, project)));
   }
 
+  private static String refUpdateType(GitReferenceUpdatedListener.Event event) {
+    String forcedPrefix = event.isNonFastForward() ? "FORCED " : " ";
+    if (event.isCreate()) {
+      return forcedPrefix + "CREATE";
+    } else if (event.isDelete()) {
+      return forcedPrefix + "DELETE";
+    } else {
+      return forcedPrefix + "UPDATE";
+    }
+  }
+
   private Boolean isRefToBeReplicated(String refName) {
     return !refsFilter.match(refName);
   }