ProjectConfig: Trim LabelValues when emitting label config
LabelValue#format for a 0 value previously prefaced the result with a
space, which then got written as a value in project.config like so:
[label "My-Label"]
value = -1 Nope
value = 0 Meh
value = +1 Yup
This arguably had an aesthetic benefit in project.config by aligning the
numbers and descriptions between the various values. However, it had no
effect on the parsed value, since JGit would trim the leading whitespace
from the config value.
This particular serialization was actually a bug in JGit: it was unable
to round-trip values starting with a single space. That bug was fixed in
https://git.eclipse.org/r/111920, which causes the side effect in Gerrit
of surrounding this config value with quotes:
[label "My-Label"]
value = -1 Nope
value = " 0 Meh"
value = +1 Yup
This still has no effect on parsing within ProjectConfig, specifically
because the splitter in parseLabelValue uses omitEmptyStrings(). But the
aesthetics are frankly now worse, so trim the value instead.
It might be worth rethinking whether LabelValue should even prepend this
space in the first place, but that is a more invasive change, e.g. it
touches GWT UI code, so we don't attempt it here.
Change-Id: Idca2a30495243d7b58f557f61016a3210d21a084
diff --git a/Documentation/config-labels.txt b/Documentation/config-labels.txt
index 532b8c42..227651a0 100644
--- a/Documentation/config-labels.txt
+++ b/Documentation/config-labels.txt
@@ -95,7 +95,7 @@
[label "Verified"]
function = MaxWithBlock
value = -1 Fails
- value = 0 No score
+ value = 0 No score
value = +1 Verified
copyAllScoresIfNoCodeChange = true
----
@@ -379,7 +379,7 @@
[label "Copyright-Check"]
function = MaxWithBlock
value = -1 Do not have copyright
- value = 0 No score
+ value = 0 No score
value = +1 Copyright clear
----
@@ -401,7 +401,7 @@
value = -3 Ohh, hell no!
value = -2 Hmm, I'm not a fan
value = -1 I'm not sure I like this
- value = 0 No score
+ value = 0 No score
value = +1 I like, but need another to like it as well
value = +2 Hmm, this is pretty nice
value = +3 Ohh, hell yes!