ProjectConfig#saveLabelSections: Save "branch" values

The branch values were not set in the config before saving, resulting
in the values being omitted from the config.

Change-Id: I95da7e27189558f98bd62c172e319be233b7b568
This commit is contained in:
David Pursehouse
2018-06-15 12:53:48 +09:00
parent 65b93383af
commit e48cb9be49
2 changed files with 14 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.project.Util;
import com.google.inject.Inject;
import java.util.Arrays;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -193,6 +194,14 @@ public class CustomLabelIT extends AbstractDaemonTest {
revision(r).review(in);
}
@Test
public void customLabel_withBranch() throws Exception {
label.setRefPatterns(Arrays.asList("master"));
saveLabelConfig();
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
assertThat(cfg.getLabelSections().get(label.getName()).getRefPatterns()).contains("master");
}
private void saveLabelConfig() throws Exception {
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
cfg.getLabelSections().put(label.getName(), label);

View File

@@ -1340,6 +1340,11 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
values.add(value.format());
}
rc.setStringList(LABEL, name, KEY_VALUE, values);
List<String> refPatterns = label.getRefPatterns();
if (refPatterns != null && !refPatterns.isEmpty()) {
rc.setStringList(LABEL, name, KEY_BRANCH, refPatterns);
}
}
for (String name : toUnset) {