diff options
author | Zalan Blenessy <zalanb@axis.com> | 2015-05-20 11:27:26 +0200 |
---|---|---|
committer | Zalan Blenessy <zalanb@axis.com> | 2015-06-02 14:34:23 +0200 |
commit | 6e6c5cd072879e5ddad553f54f453b5e5049b456 (patch) | |
tree | 96056b6896c69580de32ec1c72cbf769c00e44cb | |
parent | 1ff91c0d8213472aa8ff6e8db80f18043c7f86df (diff) |
Fixed regression caused by the defaultValue feature
[1] added support for selecting default values for labels.
Unfortunately it also broke the ability to remove labels
as described in [2], more precisely by: "To remove a label in a child
project, add an empty label with the same name as in the parent."
This fix make it possible to push empty labels in project.config
to refs/meta/config again. Without it, the following error is returned
by gerrit: 'project.config: Invalid defaultValue "0" for label ...'
[1] https://gerrit-review.googlesource.com/#/c/55750/
[2] https://gerrit-review.googlesource.com/Documentation/config-labels.html#label_custom
Change-Id: Icd727f64cb7a904957a2acc5143fe801653cfabe
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java index a905385772..351394249c 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java @@ -684,13 +684,15 @@ public class ProjectConfig extends VersionedMetaData { label.setFunctionName(null); } - short dv = (short) rc.getInt(LABEL, name, KEY_DEFAULT_VALUE, 0); - if (isInRange(dv, values)) { - label.setDefaultValue(dv); - } else { - error(new ValidationError(PROJECT_CONFIG, String.format( - "Invalid %s \"%s\" for label \"%s\"", - KEY_DEFAULT_VALUE, dv, name))); + if (!values.isEmpty()) { + short dv = (short) rc.getInt(LABEL, name, KEY_DEFAULT_VALUE, 0); + if (isInRange(dv, values)) { + label.setDefaultValue(dv); + } else { + error(new ValidationError(PROJECT_CONFIG, String.format( + "Invalid %s \"%s\" for label \"%s\"", + KEY_DEFAULT_VALUE, dv, name))); + } } label.setCopyMinScore( rc.getBoolean(LABEL, name, KEY_COPY_MIN_SCORE, false)); |