Fix bug for saving submodule subscription section config
The SubscribeSection config should be a StringList or a String.
Also fix the bug in test for overwriting SubscribeSection if you call
allowSubmoduleSubscription twice.
Change-Id: I950e9108e8521ece0f92240fa7bb137b5854d9e3
(cherry picked from commit 91fc61a883)
This commit is contained in:
@@ -143,8 +143,13 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
|
||||
Project.NameKey superName = new Project.NameKey(name(superproject));
|
||||
try (MetaDataUpdate md = metaDataUpdateFactory.create(sub)) {
|
||||
md.setMessage("Added superproject subscription");
|
||||
SubscribeSection s;
|
||||
ProjectConfig pc = ProjectConfig.read(md);
|
||||
SubscribeSection s = new SubscribeSection(superName);
|
||||
if (pc.getSubscribeSections().containsKey(superName)) {
|
||||
s = pc.getSubscribeSections().get(superName);
|
||||
} else {
|
||||
s = new SubscribeSection(superName);
|
||||
}
|
||||
String refspec;
|
||||
if (superBranch == null) {
|
||||
refspec = subBranch;
|
||||
|
||||
@@ -267,6 +267,10 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
return branchOrderSection;
|
||||
}
|
||||
|
||||
public Map<Project.NameKey, SubscribeSection> getSubscribeSections() {
|
||||
return subscribeSections;
|
||||
}
|
||||
|
||||
public Collection<SubscribeSection> getSubscribeSections(
|
||||
Branch.NameKey branch) {
|
||||
Collection<SubscribeSection> ret = new ArrayList<>();
|
||||
@@ -1248,14 +1252,19 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
||||
private void saveSubscribeSections(Config rc) {
|
||||
for (Project.NameKey p : subscribeSections.keySet()) {
|
||||
SubscribeSection s = subscribeSections.get(p);
|
||||
List<String> matchings = new ArrayList<>();
|
||||
for (RefSpec r : s.getMatchingRefSpecs()) {
|
||||
rc.setString(SUBSCRIBE_SECTION, p.get(),
|
||||
SUBSCRIBE_MATCH_REFS, r.toString());
|
||||
matchings.add(r.toString());
|
||||
}
|
||||
rc.setStringList(SUBSCRIBE_SECTION, p.get(), SUBSCRIBE_MATCH_REFS,
|
||||
matchings);
|
||||
|
||||
List<String> multimatchs = new ArrayList<>();
|
||||
for (RefSpec r : s.getMultiMatchRefSpecs()) {
|
||||
rc.setString(SUBSCRIBE_SECTION, p.get(),
|
||||
SUBSCRIBE_MULTI_MATCH_REFS, r.toString());
|
||||
multimatchs.add(r.toString());
|
||||
}
|
||||
rc.setStringList(SUBSCRIBE_SECTION, p.get(),
|
||||
SUBSCRIBE_MULTI_MATCH_REFS, multimatchs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user