Merge branch 'stable-2.15' into stable-2.16
* stable-2.15: Don't store LabelTypes in ProjectState Change-Id: I4c9b1b6347ba3ca935292c053490c42c2d3bf8d5
This commit is contained in:
@@ -75,7 +75,10 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
|
||||
/** Cached information on a project. */
|
||||
/**
|
||||
* Cached information on a project. Must not contain any data derived from parents other than it's
|
||||
* immediate parent's {@link Project.NameKey}.
|
||||
*/
|
||||
public class ProjectState {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@@ -114,9 +117,6 @@ public class ProjectState {
|
||||
/** If this is all projects, the capabilities used by the server. */
|
||||
private final CapabilityCollection capabilities;
|
||||
|
||||
/** All label types applicable to changes in this project. */
|
||||
private LabelTypes labelTypes;
|
||||
|
||||
@Inject
|
||||
public ProjectState(
|
||||
SitePaths sitePaths,
|
||||
@@ -472,10 +472,23 @@ public class ProjectState {
|
||||
|
||||
/** All available label types. */
|
||||
public LabelTypes getLabelTypes() {
|
||||
if (labelTypes == null) {
|
||||
labelTypes = loadLabelTypes();
|
||||
Map<String, LabelType> types = new LinkedHashMap<>();
|
||||
for (ProjectState s : treeInOrder()) {
|
||||
for (LabelType type : s.getConfig().getLabelSections().values()) {
|
||||
String lower = type.getName().toLowerCase();
|
||||
LabelType old = types.get(lower);
|
||||
if (old == null || old.canOverride()) {
|
||||
types.put(lower, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return labelTypes;
|
||||
List<LabelType> all = Lists.newArrayListWithCapacity(types.size());
|
||||
for (LabelType type : types.values()) {
|
||||
if (!type.getValues().isEmpty()) {
|
||||
all.add(type);
|
||||
}
|
||||
}
|
||||
return new LabelTypes(Collections.unmodifiableList(all));
|
||||
}
|
||||
|
||||
/** All available label types for this change. */
|
||||
@@ -634,26 +647,6 @@ public class ProjectState {
|
||||
return Files.exists(p) ? new String(Files.readAllBytes(p), UTF_8) : null;
|
||||
}
|
||||
|
||||
private LabelTypes loadLabelTypes() {
|
||||
Map<String, LabelType> types = new LinkedHashMap<>();
|
||||
for (ProjectState s : treeInOrder()) {
|
||||
for (LabelType type : s.getConfig().getLabelSections().values()) {
|
||||
String lower = type.getName().toLowerCase();
|
||||
LabelType old = types.get(lower);
|
||||
if (old == null || old.canOverride()) {
|
||||
types.put(lower, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<LabelType> all = Lists.newArrayListWithCapacity(types.size());
|
||||
for (LabelType type : types.values()) {
|
||||
if (!type.getValues().isEmpty()) {
|
||||
all.add(type);
|
||||
}
|
||||
}
|
||||
return new LabelTypes(Collections.unmodifiableList(all));
|
||||
}
|
||||
|
||||
private boolean match(Branch.NameKey destination, String refPattern) {
|
||||
return RefPatternMatcher.getMatcher(refPattern).match(destination.get(), null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user