Gerrit 2.14.3变更页面标签值描述文本显示配置求助
Hey there, let's figure out how to add those label value descriptions right next to the votes on your Gerrit 2.14.3 change screen! Since there's no built-in config setting for this, we'll need to customize the UI—here are two solid approaches:
Option 1: Custom Gerrit Plugin (Recommended for Long-Term Use)
This is the best path because it keeps your changes separate from Gerrit's core code, making future upgrades way less of a hassle.
- Set up a Gerrit plugin development environment that's compatible with 2.14.3 (note: newer plugin tooling won't work with this older version, so stick to the 2.14-specific plugin SDK).
- Build a plugin that hooks into the vote rendering logic on the change screen:
- Use GWT extension points to intercept the rendering of
VoteEntrywidgets. - Pull the label's definition (which includes value descriptions) from Gerrit's API—look for the
LabelValueclass, which stores both the numeric vote value and its corresponding text description. - Adjust the widget's DOM to append the description text right after the vote value. For example, change the displayed text from "-1" to "-1 Fails".
- Use GWT extension points to intercept the rendering of
Option 2: Modify Gerrit's Built-In UI Templates (Quick, but Upgrade-Sensitive)
If you need a fast fix and don't mind re-applying changes when you upgrade Gerrit, you can edit the core UI templates directly:
- Extract the Gerrit WAR file: Run
unzip gerrit.warto unpack the contents into a local directory. - Locate the vote template: For 2.14.3, the file that handles vote rendering is typically
WEB-INF/templates/change/votes.html(a Freemarker template). - Edit the vote value output: Find the line that renders the vote value—it might look like this:
Modify it to include the description by pulling from the template's context:<span class="vote-value">${vote.value}</span><span class="vote-value">${vote.value} ${vote.label.getDescriptionForValue(vote.value)}</span> - Re-package and redeploy: Zip the modified files back into a WAR with
zip -r gerrit.war *, then restart your Gerrit instance.
Critical Pre-Requisite
First, make sure your labels are already configured with descriptions in your project's project.config file—Gerrit can't display descriptions that aren't defined! For example:
[label "Verified"] function = MaxWithBlock value = -1 Fails value = 0 No score value = +1 Passes
内容的提问来源于stack exchange,提问作者Peder

