Remove deprecated API field Change-Id: I529b1064590be8c68edfc5f9f44f8ee833f13d84
diff --git a/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/api/LabelDefinition.java b/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/api/LabelDefinition.java index e128833..9152aea 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/api/LabelDefinition.java +++ b/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/api/LabelDefinition.java
@@ -24,7 +24,6 @@ public String function; public Boolean ignoreSelfApproval; public Set<String> copyScoreRules; - @Deprecated public Set<String> copyScores; public LabelDefinition() {} @@ -32,7 +31,6 @@ this.function = function; this.ignoreSelfApproval = ignoreSelfApproval; this.copyScoreRules = copyScoreRules; - this.copyScores = copyScoreRules; } public Optional<LabelFunction> getFunction() { @@ -41,7 +39,7 @@ @Override public int hashCode() { - return Objects.hash(function, ignoreSelfApproval, copyScores, copyScoreRules); + return Objects.hash(function, ignoreSelfApproval, copyScoreRules); } @Override @@ -52,7 +50,6 @@ LabelDefinition other = (LabelDefinition) o; return Objects.equals(function, other.function) && Objects.equals(ignoreSelfApproval, other.ignoreSelfApproval) - && Objects.equals(copyScores, other.copyScores) && Objects.equals(copyScoreRules, other.copyScoreRules); } @@ -61,7 +58,6 @@ return MoreObjects.toStringHelper(this) .add("function", function) .add("ignoreSelfApproval", ignoreSelfApproval) - .add("copyScores", copyScores) .add("copyScoreRules", copyScoreRules) .toString(); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/config/ConfigTranslator.java b/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/config/ConfigTranslator.java index d9dea99..64e2aa9 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/config/ConfigTranslator.java +++ b/src/main/java/com/googlesource/gerrit/plugins/simplesubmitrules/config/ConfigTranslator.java
@@ -76,8 +76,6 @@ if (labelType.isCopyAllScoresOnTrivialRebase()) { labelDefinition.copyScoreRules.add(ProjectConfig.KEY_COPY_ALL_SCORES_ON_TRIVIAL_REBASE); } - // TODO(hiesel) Remove once caller know of the new name - labelDefinition.copyScores = labelDefinition.copyScoreRules; } static void applyCopyScoreRulesTo( @@ -178,14 +176,11 @@ labelType.setFunction(function); } - // TODO(hiesel): Remove fallback to copyScores - Set<String> copyScoreRules = - definition.copyScoreRules != null ? definition.copyScoreRules : definition.copyScores; - if (copyScoreRules != null) { + if (definition.copyScoreRules != null) { Set<String> disallowedCopyScoreRules = ImmutableSet.copyOf( hostPluginConfig.getStringList("disallowedCopyScoreRules-" + label)); - applyCopyScoreRulesTo(copyScoreRules, disallowedCopyScoreRules, labelType); + applyCopyScoreRulesTo(definition.copyScoreRules, disallowedCopyScoreRules, labelType); } } }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/simplesubmitrules/PluginIT.java b/src/test/java/com/googlesource/gerrit/plugins/simplesubmitrules/PluginIT.java index fc4aefc..0bee0cb 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/simplesubmitrules/PluginIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/simplesubmitrules/PluginIT.java
@@ -160,27 +160,6 @@ assertThat(response.labels.get("Code-Review").ignoreSelfApproval).isTrue(); } - @Test - public void copyScoreRulesApiFieldIsBackwardsCompatible() throws Exception { - LabelDefinition codeReviewNoSelfApproval = - new LabelDefinition("MaxNoBlock", true, ImmutableSet.of("copyAllScoresIfNoChange")); - codeReviewNoSelfApproval.copyScores = codeReviewNoSelfApproval.copyScoreRules; - // Use only deprecated API field, set the new one to NULL - codeReviewNoSelfApproval.copyScoreRules = null; - - SubmitConfig config = - new SubmitConfig(ImmutableMap.of("Code-Review", codeReviewNoSelfApproval), null); - postConfig(project, config); - - String currentConfig = adminRestSession.get(endpointUrl(project)).getEntityContent(); - SubmitConfig parsedConfig = newGson().fromJson(currentConfig, SubmitConfig.class); - assertThat(parsedConfig.labels.keySet()).containsExactly("Code-Review"); - - LabelDefinition result = parsedConfig.labels.get("Code-Review"); - assertThat(result.copyScoreRules).isEqualTo(result.copyScores); - assertThat(result.copyScoreRules).isEqualTo(codeReviewNoSelfApproval.copyScores); - } - private SubmitConfig postConfig(Project.NameKey project, SubmitConfig config) throws Exception { RawInput rawInput = RawInputUtil.create(newGson().toJson(config).getBytes(Charsets.UTF_8), JSON_TYPE);