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:
Zhen Chen
2016-10-13 15:14:28 -07:00
parent 60127bde78
commit d3780df476
2 changed files with 19 additions and 5 deletions

View File

@@ -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);
}
}