Never replicate automerge-cache commits
Whenever a change is diffed in the UI, the merge result is stored
as a commit under the refs/automerge-cache namespace in the related
git. These commits are then replicated, which is not necessary.
Add checks to prevent these commits from being replicated.
Change-Id: Ia1896a822a9901918d318d7641e2e8b63a0cf355
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
index ddcb933..46a6d00 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -417,7 +417,7 @@
boolean noPerms = !pool.isReplicatePermissions();
Map<String, Ref> remote = listRemote(tn);
for (Ref src : local.values()) {
- if (noPerms && RefNames.REFS_CONFIG.equals(src.getName())) {
+ if (!canPushRef(src.getName(), noPerms)) {
continue;
}
@@ -454,8 +454,7 @@
if (spec != null) {
// If the ref still exists locally, send it, otherwise delete it.
Ref srcRef = local.get(src);
- if (srcRef != null &&
- !(noPerms && RefNames.REFS_CONFIG.equals(src))) {
+ if (srcRef != null && canPushRef(src, noPerms)) {
push(cmds, spec, srcRef);
} else if (config.isMirror()) {
delete(cmds, spec);
@@ -465,6 +464,11 @@
return cmds;
}
+ private boolean canPushRef(String ref, boolean noPerms) {
+ return !(noPerms && RefNames.REFS_CONFIG.equals(ref)) &&
+ !ref.startsWith(RefNames.REFS_CACHE_AUTOMERGE);
+ }
+
private Map<String, Ref> listRemote(Transport tn)
throws NotSupportedException, TransportException {
FetchConnection fc = tn.openFetch();