SubmoduleOp: sort subscriptions before creating gitlink commit message
This commit makes sure that the commit message for the super repo is created with an sorted list of subscriptions. Without this fix, the following test could fail because the commit message may change for different runs. SubmoduleSubscriptionsWholeTopicMergeIT#updateManySubmodules Change-Id: If84195c04fb89b1397295d0d80b6b697f20598e4
This commit is contained in:
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.git;
|
package com.google.gerrit.server.git;
|
||||||
|
|
||||||
|
import static java.util.Comparator.comparing;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.MultimapBuilder;
|
import com.google.common.collect.MultimapBuilder;
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
@@ -47,6 +49,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -416,7 +419,10 @@ public class SubmoduleOp {
|
|||||||
DirCache dc = readTree(or.rw, currentCommit);
|
DirCache dc = readTree(or.rw, currentCommit);
|
||||||
DirCacheEditor ed = dc.editor();
|
DirCacheEditor ed = dc.editor();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (SubmoduleSubscription s : targets.get(subscriber)) {
|
|
||||||
|
List<SubmoduleSubscription> subscriptions = new ArrayList<>(targets.get(subscriber));
|
||||||
|
Collections.sort(subscriptions, comparing((SubmoduleSubscription s) -> s.getPath()));
|
||||||
|
for (SubmoduleSubscription s : subscriptions) {
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
msgbuf.append("\n\n");
|
msgbuf.append("\n\n");
|
||||||
}
|
}
|
||||||
|
@@ -346,17 +346,17 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
|
|||||||
"master",
|
"master",
|
||||||
"Update git submodules\n\n"
|
"Update git submodules\n\n"
|
||||||
+ "* Update "
|
+ "* Update "
|
||||||
+ name("sub3")
|
+ name("sub1")
|
||||||
+ " from branch 'master'\n to "
|
+ " from branch 'master'\n to "
|
||||||
+ sub3HEAD
|
+ sub1HEAD
|
||||||
+ "\n\n* Update "
|
+ "\n\n* Update "
|
||||||
+ name("sub2")
|
+ name("sub2")
|
||||||
+ " from branch 'master'\n to "
|
+ " from branch 'master'\n to "
|
||||||
+ sub2HEAD
|
+ sub2HEAD
|
||||||
+ "\n\n* Update "
|
+ "\n\n* Update "
|
||||||
+ name("sub1")
|
+ name("sub3")
|
||||||
+ " from branch 'master'\n to "
|
+ " from branch 'master'\n to "
|
||||||
+ sub1HEAD);
|
+ sub3HEAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
superRepo
|
superRepo
|
||||||
|
Reference in New Issue
Block a user