Report deletions as succeeded in the fetch-ref-replicated events
The refs deletions were always reported as failing on the stream event
fetch-ref-replicated, because of a mismatch in the ref-spec reported for
deletions.
Prefix the refs deletions with ":", as per git specs[1], for reporting
them correctly in the status map and therefore generating more useful
events on the replication status.
[1] https://git-scm.com/book/en/v2/Git-Internals-The-Refspec under
"Deleting References"
Change-Id: Ibd1b9c97cdc79f4972a65cba8001530bf0a64ab5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/DeleteRefCommand.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/DeleteRefCommand.java
index fe558e5..c3f91d6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/DeleteRefCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/DeleteRefCommand.java
@@ -73,7 +73,7 @@
name.get(),
r,
sourceLabel);
- return new RefUpdateState(r, RefUpdate.Result.IO_FAILURE);
+ return new RefUpdateState(":" + r, RefUpdate.Result.IO_FAILURE);
}
})
.toList();
@@ -95,7 +95,7 @@
taskIdRef,
refName,
name);
- return new RefUpdateState(refName, RefUpdate.Result.NO_CHANGE);
+ return new RefUpdateState(":" + refName, RefUpdate.Result.NO_CHANGE);
}
repLog.info(
@@ -112,7 +112,7 @@
Optional<Ref> ref = getRef(name, refName);
if (!ref.isPresent()) {
logger.atFine().log("[%s] Ref %s was not found in project %s", taskIdRef, refName, name);
- return new RefUpdateState(refName, RefUpdate.Result.NO_CHANGE);
+ return new RefUpdateState(":" + refName, RefUpdate.Result.NO_CHANGE);
}
RefUpdateState deleteResult = deleteRef(name, ref.get());
@@ -149,7 +149,7 @@
u.setForceUpdate(true);
result = u.delete();
- return new RefUpdateState(ref.getName(), result);
+ return new RefUpdateState(":" + ref.getName(), result);
}
}