Allow to use refspec shortcuts for push replication
Documentation states [1] that one can use a short refspec for 'push'
replication. This fix actually makes it possible.
1) http://gerrit.googlecode.com/svn/documentation/2.0/config-replication.html
Bug: issue 658
Change-Id: Icbd61088ddac2ad627267bd7cf6a620498a00bf7
[cherry-picked from 47be12b9f3b74ef0b4d36d47b4a34deebe568e55]
Change-Id: I57feb280bef7b89d51a313f160ea383ce4495294
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/PushReplication.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/PushReplication.java
index 76b8bf0..f26bf65 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/PushReplication.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/PushReplication.java
@@ -163,6 +163,14 @@
}
}
+ // In case if refspec destination for push is not set then we assume it is equal to source
+ for (RefSpec ref : c.getPushRefSpecs()) {
+ if (ref.getDestination() == null) {
+ ref.setDestination(ref.getSource());
+ }
+ }
+
+
if (c.getPushRefSpecs().isEmpty()) {
RefSpec spec = new RefSpec();
spec = spec.setSourceDestination("refs/*", "refs/*");
@@ -193,21 +201,17 @@
return result;
}
+ @Override
public void replicateNewProject(Project.NameKey projectName, String head) {
if (!isEnabled()) {
return;
}
- Iterator<ReplicationConfig> configIter = configs.iterator();
+ for (ReplicationConfig config : configs) {
+ List<URIish> uriList = config.getURIs(projectName, "*");
- while (configIter.hasNext()) {
- ReplicationConfig rp = configIter.next();
- List<URIish> uriList = rp.getURIs(projectName, "*");
-
- Iterator<URIish> uriIter = uriList.iterator();
-
- while (uriIter.hasNext()) {
- replicateProject(uriIter.next(), head);
+ for (URIish uri : uriList) {
+ replicateProject(uri, head);
}
}
}
@@ -266,6 +270,7 @@
private StringBuilder all = new StringBuilder();
private StringBuilder sb = new StringBuilder();
+ @Override
public String toString() {
String r = all.toString();
while (r.endsWith("\n"))