Merge "Merge branch 'stable-3.10'"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/AbstractMultisiteReplicationFilter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/AbstractMultisiteReplicationFilter.java
new file mode 100644
index 0000000..bf4a0f9
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/AbstractMultisiteReplicationFilter.java
@@ -0,0 +1,33 @@
+// Copyright (C) 2024 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.multisite.validation;
+
+import static com.googlesource.gerrit.plugins.multisite.validation.ProjectVersionRefUpdate.MULTI_SITE_VERSIONING_REF;
+
+abstract class AbstractMultisiteReplicationFilter {
+
+ /*
+ * Since ac43a5f94c773c9db7a73d44035961d69d13fa53 the 'refs/multi-site/version' is
+ * not updated anymore on the global-refdb; however, the values stored already
+ * on the global-refdb could get in the way and prevent replication from happening
+ * as expected.
+ *
+ * Exclude the 'refs/multi-site/version' from local vs. global refdb checking
+ * pretending that the global-refdb for that ref did not exist.
+ */
+ protected boolean shouldNotBeTrackedAnymoreOnGlobalRefDb(String ref) {
+ return MULTI_SITE_VERSIONING_REF.equals(ref);
+ }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java
index 3fc57ae..c5571c0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java
@@ -14,7 +14,6 @@
package com.googlesource.gerrit.plugins.multisite.validation;
-import static com.googlesource.gerrit.plugins.multisite.validation.ProjectVersionRefUpdate.MULTI_SITE_VERSIONING_REF;
import static com.googlesource.gerrit.plugins.replication.pull.PullReplicationLogger.repLog;
import com.gerritforge.gerrit.globalrefdb.GlobalRefDbLockException;
@@ -38,7 +37,8 @@
import org.eclipse.jgit.lib.Repository;
@Singleton
-public class MultisiteReplicationFetchFilter implements ReplicationFetchFilter {
+public class MultisiteReplicationFetchFilter extends AbstractMultisiteReplicationFilter
+ implements ReplicationFetchFilter {
private static final String ZERO_ID_NAME = ObjectId.zeroId().name();
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@@ -91,19 +91,6 @@
}
}
- /*
- * Since ac43a5f94c773c9db7a73d44035961d69d13fa53 the 'refs/multi-site/version' is
- * not updated anymore on the global-refdb; however, the values stored already
- * on the global-refdb could get in the way and prevent replication from happening
- * as expected.
- *
- * Exclude the 'refs/multi-site/version' from local vs. global refdb checking
- * pretending that the global-refdb for that ref did not exist.
- */
- private boolean shouldNotBeTrackedAnymoreOnGlobalRefDb(String ref) {
- return MULTI_SITE_VERSIONING_REF.equals(ref);
- }
-
/* If the ref to fetch has been set to all zeros on the global-refdb, it means
* that whatever is the situation locally, we do not need to fetch it:
* - If the remote still has it, fetching it will be useless because the global
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java
index f076b7f..5955e17 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java
@@ -40,7 +40,8 @@
import org.slf4j.LoggerFactory;
@Singleton
-public class MultisiteReplicationPushFilter implements ReplicationPushFilter {
+public class MultisiteReplicationPushFilter extends AbstractMultisiteReplicationFilter
+ implements ReplicationPushFilter {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private static final String REF_META_SUFFIX = "/meta";
@@ -111,6 +112,10 @@
private Optional<RemoteRefUpdate> isUpToDateWithRetry(
String projectName, Repository repository, RemoteRefUpdate refUpdate) {
+ if (shouldNotBeTrackedAnymoreOnGlobalRefDb(refUpdate.getSrcRef())) {
+ return Optional.of(refUpdate);
+ }
+
String ref = refUpdate.getSrcRef();
try {
if (sharedRefDb.isUpToDate(