Label abbreviation feature is dead; kill it
Note: because this feature wasn't used at all, there is no need for new schema version with automagic gerrit.config clean up. Bug: issue 2618 Change-Id: Ic129ca43c21c1955b842d61b84c515d622711ced
This commit is contained in:

committed by
Dave Borowitz

parent
1e05b52046
commit
4f0c338788
@@ -183,14 +183,6 @@ range for a user. In that case the score that will get set in the Reply
|
||||
box will be either the lowest or highest score in the permissible range.
|
||||
|
||||
|
||||
[[label_abbreviation]]
|
||||
=== `label.Label-Name.abbreviation`
|
||||
|
||||
An abbreviated name for a label shown as a compact column header, for
|
||||
example on project dashboards. Defaults to all the uppercase characters
|
||||
in the label name, e.g. `Label-Name` is abbreviated by default as `LN`.
|
||||
|
||||
|
||||
[[label_function]]
|
||||
=== `label.Label-Name.function`
|
||||
|
||||
|
@@ -60,7 +60,7 @@ public class LabelType {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String defaultAbbreviation(String name) {
|
||||
private static String getAbbreviation(String name) {
|
||||
StringBuilder abbr = new StringBuilder();
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
char c = name.charAt(i);
|
||||
@@ -128,7 +128,7 @@ public class LabelType {
|
||||
values = sortValues(valueList);
|
||||
defaultValue = 0;
|
||||
|
||||
abbreviation = defaultAbbreviation(name);
|
||||
abbreviation = getAbbreviation(name);
|
||||
functionName = "MaxWithBlock";
|
||||
|
||||
maxNegative = Short.MIN_VALUE;
|
||||
@@ -151,14 +151,6 @@ public class LabelType {
|
||||
return psa.getLabelId().get().equalsIgnoreCase(name);
|
||||
}
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public String getFunctionName() {
|
||||
return functionName;
|
||||
}
|
||||
|
@@ -130,7 +130,6 @@ public class ProjectConfig extends VersionedMetaData {
|
||||
private static final String KEY_LOCAL_DEFAULT = "local-default";
|
||||
|
||||
private static final String LABEL = "label";
|
||||
private static final String KEY_ABBREVIATION = "abbreviation";
|
||||
private static final String KEY_FUNCTION = "function";
|
||||
private static final String KEY_DEFAULT_VALUE = "defaultValue";
|
||||
private static final String KEY_COPY_MIN_SCORE = "copyMinScore";
|
||||
@@ -673,10 +672,6 @@ public class ProjectConfig extends VersionedMetaData {
|
||||
"Invalid label \"%s\"", name)));
|
||||
continue;
|
||||
}
|
||||
String abbr = rc.getString(LABEL, name, KEY_ABBREVIATION);
|
||||
if (abbr != null) {
|
||||
label.setAbbreviation(abbr);
|
||||
}
|
||||
|
||||
String functionName = Objects.firstNonNull(
|
||||
rc.getString(LABEL, name, KEY_FUNCTION), "MaxWithBlock");
|
||||
@@ -1050,15 +1045,6 @@ public class ProjectConfig extends VersionedMetaData {
|
||||
LabelType label = e.getValue();
|
||||
toUnset.remove(name);
|
||||
rc.setString(LABEL, name, KEY_FUNCTION, label.getFunctionName());
|
||||
|
||||
if (!LabelType.defaultAbbreviation(name)
|
||||
.equals(label.getAbbreviation())) {
|
||||
rc.setString(
|
||||
LABEL, name, KEY_ABBREVIATION, label.getAbbreviation());
|
||||
} else {
|
||||
rc.unset(LABEL, name, KEY_ABBREVIATION);
|
||||
}
|
||||
|
||||
rc.setInt(LABEL, name, KEY_DEFAULT_VALUE, label.getDefaultValue());
|
||||
if (label.isCopyMinScore()) {
|
||||
rc.setBoolean(LABEL, name, KEY_COPY_MIN_SCORE, true);
|
||||
|
@@ -103,12 +103,6 @@ class EqualsLabelPredicate extends IndexPredicate<ChangeData> {
|
||||
return lt;
|
||||
}
|
||||
}
|
||||
|
||||
for (LabelType lt : types.getLabelTypes()) {
|
||||
if (toFind.equalsIgnoreCase(lt.getAbbreviation())) {
|
||||
return lt;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -215,7 +215,6 @@ public class AllProjectsCreator {
|
||||
new LabelValue((short) 0, "No score"),
|
||||
new LabelValue((short) -1, "I would prefer this is not merged as is"),
|
||||
new LabelValue((short) -2, "This shall not be merged")));
|
||||
type.setAbbreviation("CR");
|
||||
type.setCopyMinScore(true);
|
||||
c.getLabelSections().put(type.getName(), type);
|
||||
return type;
|
||||
|
@@ -203,8 +203,7 @@ public class Schema_77 extends SchemaVersion {
|
||||
Statement catStmt = ((JdbcSchema) db).getConnection().createStatement();
|
||||
try {
|
||||
ResultSet catRs = catStmt.executeQuery(
|
||||
"SELECT category_id, name, abbreviated_name, function_name, "
|
||||
+ " copy_min_score"
|
||||
"SELECT category_id, name, function_name, copy_min_score"
|
||||
+ " FROM approval_categories"
|
||||
+ " ORDER BY position, name");
|
||||
PreparedStatement valStmt = ((JdbcSchema) db).getConnection().prepareStatement(
|
||||
@@ -224,7 +223,6 @@ public class Schema_77 extends SchemaVersion {
|
||||
LegacyLabelType type =
|
||||
new LegacyLabelType(getLabelName(catRs.getString("name")), values);
|
||||
type.setId(id);
|
||||
type.setAbbreviation(catRs.getString("abbreviated_name"));
|
||||
type.setFunctionName(catRs.getString("function_name"));
|
||||
type.setCopyMinScore("Y".equals(catRs.getString("copy_min_score")));
|
||||
types.add(type);
|
||||
|
@@ -128,7 +128,6 @@ public class SchemaCreatorTest {
|
||||
LabelType codeReview = getLabelTypes().byLabel("Code-Review");
|
||||
assertNotNull(codeReview);
|
||||
assertEquals("Code-Review", codeReview.getName());
|
||||
assertEquals("CR", codeReview.getAbbreviation());
|
||||
assertEquals(0, codeReview.getDefaultValue());
|
||||
assertEquals("MaxWithBlock", codeReview.getFunctionName());
|
||||
assertTrue(codeReview.isCopyMinScore());
|
||||
|
Reference in New Issue
Block a user