in src/main/java/com/googlesource/gerrit/plugins/automerger/ConfigLoader.java [215:239]
public Set<String> getUpstreamBranches(String toBranch, String project)
throws ConfigInvalidException, RestApiException, IOException {
if (toBranch == null) {
throw new IllegalArgumentException("toBranch cannot be null");
}
Set<String> upstreamBranches = new HashSet<>();
// List all subsections of automerger, split by :
Set<String> subsections = getConfig().getSubsections(pluginName);
for (String subsection : subsections) {
// Subsections are of the form "fromBranch:toBranch"
List<String> branchPair =
Splitter.on(BRANCH_DELIMITER).trimResults().omitEmptyStrings().splitToList(subsection);
if (branchPair.size() != 2) {
throw new ConfigInvalidException("Automerger config branch pair malformed: " + subsection);
}
if (toBranch.equals(branchPair.get(1))) {
// If toBranch matches, check if project is in both their manifests
Set<String> projectsInScope = getProjectsInScope(branchPair.get(0), branchPair.get(1));
if (projectsInScope.contains(project)) {
upstreamBranches.add(branchPair.get(0));
}
}
}
return upstreamBranches;
}